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

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

Issue 2489373002: [Mac] (More) RTL support for tab strip (Closed)
Patch Set: Created 4 years, 1 month 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
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 <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "base/mac/scoped_nsobject.h" 7 #include "base/mac/scoped_nsobject.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #import "chrome/browser/ui/cocoa/browser_window_layout.h" 9 #import "chrome/browser/ui/cocoa/browser_window_layout.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 private: 54 private:
55 DISALLOW_COPY_AND_ASSIGN(BrowserWindowLayoutTest); 55 DISALLOW_COPY_AND_ASSIGN(BrowserWindowLayoutTest);
56 }; 56 };
57 57
58 TEST_F(BrowserWindowLayoutTest, TestAllViews) { 58 TEST_F(BrowserWindowLayoutTest, TestAllViews) {
59 chrome::LayoutOutput output = [layout computeLayout]; 59 chrome::LayoutOutput output = [layout computeLayout];
60 60
61 EXPECT_NSEQ(NSMakeRect(0, 585, 600, 37), output.tabStripLayout.frame); 61 EXPECT_NSEQ(NSMakeRect(0, 585, 600, 37), output.tabStripLayout.frame);
62 EXPECT_NSEQ(NSMakeRect(502, 589, 63, 28), output.tabStripLayout.avatarFrame); 62 EXPECT_NSEQ(NSMakeRect(502, 589, 63, 28), output.tabStripLayout.avatarFrame);
63 EXPECT_EQ(70, output.tabStripLayout.leftIndent); 63 EXPECT_EQ(70, output.tabStripLayout.leadingIndent);
64 EXPECT_EQ(98, output.tabStripLayout.rightIndent); 64 EXPECT_EQ(98, output.tabStripLayout.trailingIndent);
65 EXPECT_NSEQ(NSMakeRect(0, 553, 600, 32), output.toolbarFrame); 65 EXPECT_NSEQ(NSMakeRect(0, 553, 600, 32), output.toolbarFrame);
66 EXPECT_NSEQ(NSMakeRect(0, 527, 600, 26), output.bookmarkFrame); 66 EXPECT_NSEQ(NSMakeRect(0, 527, 600, 26), output.bookmarkFrame);
67 EXPECT_NSEQ(NSZeroRect, output.fullscreenBackingBarFrame); 67 EXPECT_NSEQ(NSZeroRect, output.fullscreenBackingBarFrame);
68 EXPECT_EQ(527, output.findBarMaxY); 68 EXPECT_EQ(527, output.findBarMaxY);
69 EXPECT_NSEQ(NSMakeRect(0, 455, 600, 111), output.infoBarFrame); 69 EXPECT_NSEQ(NSMakeRect(0, 455, 600, 111), output.infoBarFrame);
70 EXPECT_NSEQ(NSMakeRect(0, 0, 600, 44), output.downloadShelfFrame); 70 EXPECT_NSEQ(NSMakeRect(0, 0, 600, 44), output.downloadShelfFrame);
71 EXPECT_NSEQ(NSMakeRect(0, 44, 600, 411), output.contentAreaFrame); 71 EXPECT_NSEQ(NSMakeRect(0, 44, 600, 411), output.contentAreaFrame);
72 } 72 }
73 73
74 TEST_F(BrowserWindowLayoutTest, TestAllViewsFullscreen) { 74 TEST_F(BrowserWindowLayoutTest, TestAllViewsFullscreen) {
75 ApplyStandardFullscreenLayoutParameters(); 75 ApplyStandardFullscreenLayoutParameters();
76 76
77 chrome::LayoutOutput output = [layout computeLayout]; 77 chrome::LayoutOutput output = [layout computeLayout];
78 78
79 EXPECT_NSEQ(NSMakeRect(0, 585, 600, 37), output.tabStripLayout.frame); 79 EXPECT_NSEQ(NSMakeRect(0, 585, 600, 37), output.tabStripLayout.frame);
80 EXPECT_NSEQ(NSMakeRect(533, 589, 63, 28), output.tabStripLayout.avatarFrame); 80 EXPECT_NSEQ(NSMakeRect(533, 589, 63, 28), output.tabStripLayout.avatarFrame);
81 EXPECT_EQ(0, output.tabStripLayout.leftIndent); 81 EXPECT_EQ(0, output.tabStripLayout.leadingIndent);
82 EXPECT_FALSE(output.tabStripLayout.addCustomWindowControls); 82 EXPECT_FALSE(output.tabStripLayout.addCustomWindowControls);
83 EXPECT_EQ(67, output.tabStripLayout.rightIndent); 83 EXPECT_EQ(67, output.tabStripLayout.trailingIndent);
84 EXPECT_NSEQ(NSMakeRect(0, 553, 600, 32), output.toolbarFrame); 84 EXPECT_NSEQ(NSMakeRect(0, 553, 600, 32), output.toolbarFrame);
85 EXPECT_NSEQ(NSMakeRect(0, 527, 600, 26), output.bookmarkFrame); 85 EXPECT_NSEQ(NSMakeRect(0, 527, 600, 26), output.bookmarkFrame);
86 EXPECT_NSEQ(NSMakeRect(0, 527, 600, 95), output.fullscreenBackingBarFrame); 86 EXPECT_NSEQ(NSMakeRect(0, 527, 600, 95), output.fullscreenBackingBarFrame);
87 EXPECT_EQ(527, output.findBarMaxY); 87 EXPECT_EQ(527, output.findBarMaxY);
88 EXPECT_NSEQ(NSMakeRect(0, 455, 600, 111), output.infoBarFrame); 88 EXPECT_NSEQ(NSMakeRect(0, 455, 600, 111), output.infoBarFrame);
89 EXPECT_NSEQ(NSMakeRect(0, 0, 600, 44), output.downloadShelfFrame); 89 EXPECT_NSEQ(NSMakeRect(0, 0, 600, 44), output.downloadShelfFrame);
90 EXPECT_NSEQ(NSMakeRect(0, 44, 600, 411), output.contentAreaFrame); 90 EXPECT_NSEQ(NSMakeRect(0, 44, 600, 411), output.contentAreaFrame);
91 } 91 }
92 92
93 // In fullscreen mode for Yosemite, the tab strip's left indent should be 93 // In fullscreen mode for Yosemite, the tab strip's left indent should be
94 // sufficiently large to accomodate the addition of traffic light buttons. 94 // sufficiently large to accomodate the addition of traffic light buttons.
95 TEST_F(BrowserWindowLayoutTest, TestYosemiteFullscreenTrafficLights) { 95 TEST_F(BrowserWindowLayoutTest, TestYosemiteFullscreenTrafficLights) {
96 ApplyStandardFullscreenLayoutParameters(); 96 ApplyStandardFullscreenLayoutParameters();
97 [layout setOSYosemiteOrLater:YES]; 97 [layout setOSYosemiteOrLater:YES];
98 98
99 chrome::LayoutOutput output = [layout computeLayout]; 99 chrome::LayoutOutput output = [layout computeLayout];
100 100
101 EXPECT_EQ(70, output.tabStripLayout.leftIndent); 101 EXPECT_EQ(70, output.tabStripLayout.leadingIndent);
102 EXPECT_TRUE(output.tabStripLayout.addCustomWindowControls); 102 EXPECT_TRUE(output.tabStripLayout.addCustomWindowControls);
103 } 103 }
104 104
105 TEST_F(BrowserWindowLayoutTest, TestAllViewsFullscreenMenuBarShowing) { 105 TEST_F(BrowserWindowLayoutTest, TestAllViewsFullscreenMenuBarShowing) {
106 ApplyStandardFullscreenLayoutParameters(); 106 ApplyStandardFullscreenLayoutParameters();
107 [layout setFullscreenMenubarOffset:-10]; 107 [layout setFullscreenMenubarOffset:-10];
108 108
109 chrome::LayoutOutput output = [layout computeLayout]; 109 chrome::LayoutOutput output = [layout computeLayout];
110 110
111 EXPECT_NSEQ(NSMakeRect(0, 575, 600, 37), output.tabStripLayout.frame); 111 EXPECT_NSEQ(NSMakeRect(0, 575, 600, 37), output.tabStripLayout.frame);
112 EXPECT_NSEQ(NSMakeRect(533, 579, 63, 28), output.tabStripLayout.avatarFrame); 112 EXPECT_NSEQ(NSMakeRect(533, 579, 63, 28), output.tabStripLayout.avatarFrame);
113 EXPECT_EQ(0, output.tabStripLayout.leftIndent); 113 EXPECT_EQ(0, output.tabStripLayout.leadingIndent);
114 EXPECT_FALSE(output.tabStripLayout.addCustomWindowControls); 114 EXPECT_FALSE(output.tabStripLayout.addCustomWindowControls);
115 EXPECT_EQ(67, output.tabStripLayout.rightIndent); 115 EXPECT_EQ(67, output.tabStripLayout.trailingIndent);
116 EXPECT_NSEQ(NSMakeRect(0, 543, 600, 32), output.toolbarFrame); 116 EXPECT_NSEQ(NSMakeRect(0, 543, 600, 32), output.toolbarFrame);
117 EXPECT_NSEQ(NSMakeRect(0, 517, 600, 26), output.bookmarkFrame); 117 EXPECT_NSEQ(NSMakeRect(0, 517, 600, 26), output.bookmarkFrame);
118 EXPECT_NSEQ(NSMakeRect(0, 517, 600, 95), output.fullscreenBackingBarFrame); 118 EXPECT_NSEQ(NSMakeRect(0, 517, 600, 95), output.fullscreenBackingBarFrame);
119 EXPECT_EQ(517, output.findBarMaxY); 119 EXPECT_EQ(517, output.findBarMaxY);
120 EXPECT_NSEQ(NSMakeRect(0, 445, 600, 111), output.infoBarFrame); 120 EXPECT_NSEQ(NSMakeRect(0, 445, 600, 111), output.infoBarFrame);
121 EXPECT_NSEQ(NSMakeRect(0, 0, 600, 44), output.downloadShelfFrame); 121 EXPECT_NSEQ(NSMakeRect(0, 0, 600, 44), output.downloadShelfFrame);
122 EXPECT_NSEQ(NSMakeRect(0, 44, 600, 411), output.contentAreaFrame); 122 EXPECT_NSEQ(NSMakeRect(0, 44, 600, 411), output.contentAreaFrame);
123 } 123 }
124 124
125 TEST_F(BrowserWindowLayoutTest, TestPopupWindow) { 125 TEST_F(BrowserWindowLayoutTest, TestPopupWindow) {
126 [layout setHasTabStrip:NO]; 126 [layout setHasTabStrip:NO];
127 [layout setHasToolbar:NO]; 127 [layout setHasToolbar:NO];
128 [layout setHasLocationBar:YES]; 128 [layout setHasLocationBar:YES];
129 [layout setBookmarkBarHidden:YES]; 129 [layout setBookmarkBarHidden:YES];
130 [layout setHasDownloadShelf:NO]; 130 [layout setHasDownloadShelf:NO];
131 131
132 chrome::LayoutOutput output = [layout computeLayout]; 132 chrome::LayoutOutput output = [layout computeLayout];
133 133
134 EXPECT_NSEQ(NSZeroRect, output.tabStripLayout.frame); 134 EXPECT_NSEQ(NSZeroRect, output.tabStripLayout.frame);
135 EXPECT_NSEQ(NSZeroRect, output.tabStripLayout.avatarFrame); 135 EXPECT_NSEQ(NSZeroRect, output.tabStripLayout.avatarFrame);
136 EXPECT_EQ(0, output.tabStripLayout.leftIndent); 136 EXPECT_EQ(0, output.tabStripLayout.leadingIndent);
137 EXPECT_EQ(0, output.tabStripLayout.rightIndent); 137 EXPECT_EQ(0, output.tabStripLayout.trailingIndent);
138 EXPECT_NSEQ(NSMakeRect(1, 568, 598, 32), output.toolbarFrame); 138 EXPECT_NSEQ(NSMakeRect(1, 568, 598, 32), output.toolbarFrame);
139 EXPECT_NSEQ(NSZeroRect, output.bookmarkFrame); 139 EXPECT_NSEQ(NSZeroRect, output.bookmarkFrame);
140 EXPECT_NSEQ(NSZeroRect, output.fullscreenBackingBarFrame); 140 EXPECT_NSEQ(NSZeroRect, output.fullscreenBackingBarFrame);
141 EXPECT_EQ(567, output.findBarMaxY); 141 EXPECT_EQ(567, output.findBarMaxY);
142 EXPECT_NSEQ(NSMakeRect(0, 495, 600, 72), output.infoBarFrame); 142 EXPECT_NSEQ(NSMakeRect(0, 495, 600, 72), output.infoBarFrame);
143 EXPECT_NSEQ(NSZeroRect, output.downloadShelfFrame); 143 EXPECT_NSEQ(NSZeroRect, output.downloadShelfFrame);
144 EXPECT_NSEQ(NSMakeRect(0, 0, 600, 495), output.contentAreaFrame); 144 EXPECT_NSEQ(NSMakeRect(0, 0, 600, 495), output.contentAreaFrame);
145 } 145 }
146 146
147 // Old style avatar button is on the right of the fullscreen button. 147 // Old style avatar button is on the right of the fullscreen button.
148 // The tab strip's right indent goes up to the left side of the fullscreen 148 // The tab strip's right indent goes up to the left side of the fullscreen
149 // button. 149 // button.
150 TEST_F(BrowserWindowLayoutTest, TestOldStyleAvatarButton) { 150 TEST_F(BrowserWindowLayoutTest, TestOldStyleAvatarButton) {
151 NSRect fullscreenButtonFrame = NSMakeRect(510, 596, 16, 17); 151 NSRect fullscreenButtonFrame = NSMakeRect(510, 596, 16, 17);
152 [layout setFullscreenButtonFrame:fullscreenButtonFrame]; 152 [layout setFullscreenButtonFrame:fullscreenButtonFrame];
153 [layout setShouldUseNewAvatar:NO]; 153 [layout setShouldUseNewAvatar:NO];
154 154
155 chrome::TabStripLayout tabStripLayout = [layout computeLayout].tabStripLayout; 155 chrome::TabStripLayout tabStripLayout = [layout computeLayout].tabStripLayout;
156 156
157 EXPECT_LE(NSMaxX(fullscreenButtonFrame), NSMinX(tabStripLayout.avatarFrame)); 157 EXPECT_LE(NSMaxX(fullscreenButtonFrame), NSMinX(tabStripLayout.avatarFrame));
158 EXPECT_EQ(NSWidth(tabStripLayout.frame) - NSMinX(fullscreenButtonFrame), 158 EXPECT_EQ(NSWidth(tabStripLayout.frame) - NSMinX(fullscreenButtonFrame),
159 tabStripLayout.rightIndent); 159 tabStripLayout.trailingIndent);
160 } 160 }
161 161
162 // New style avatar button is on the left of the fullscreen button. 162 // New style avatar button is on the left of the fullscreen button.
163 // The tab strip's right indent goes up to the left side of the avatar button. 163 // The tab strip's right indent goes up to the left side of the avatar button.
164 TEST_F(BrowserWindowLayoutTest, TestNewStyleAvatarButton) { 164 TEST_F(BrowserWindowLayoutTest, TestNewStyleAvatarButton) {
165 NSRect fullscreenButtonFrame = NSMakeRect(575, 596, 16, 17); 165 NSRect fullscreenButtonFrame = NSMakeRect(575, 596, 16, 17);
166 [layout setFullscreenButtonFrame:fullscreenButtonFrame]; 166 [layout setFullscreenButtonFrame:fullscreenButtonFrame];
167 [layout setShouldUseNewAvatar:YES]; 167 [layout setShouldUseNewAvatar:YES];
168 168
169 chrome::TabStripLayout tabStripLayout = [layout computeLayout].tabStripLayout; 169 chrome::TabStripLayout tabStripLayout = [layout computeLayout].tabStripLayout;
170 170
171 EXPECT_LE(NSMaxX(tabStripLayout.avatarFrame), NSMinX(fullscreenButtonFrame)); 171 EXPECT_LE(NSMaxX(tabStripLayout.avatarFrame), NSMinX(fullscreenButtonFrame));
172 EXPECT_EQ(NSWidth(tabStripLayout.frame) - NSMinX(tabStripLayout.avatarFrame), 172 EXPECT_EQ(NSWidth(tabStripLayout.frame) - NSMinX(tabStripLayout.avatarFrame),
173 tabStripLayout.rightIndent); 173 tabStripLayout.trailingIndent);
174 } 174 }
175 175
176 // There is no fullscreen button when in fullscreen mode. 176 // There is no fullscreen button when in fullscreen mode.
177 // The tab strip's right indent goes up to the left side of the avatar 177 // The tab strip's right indent goes up to the left side of the avatar
178 // button. 178 // button.
179 TEST_F(BrowserWindowLayoutTest, TestAvatarButtonFullscreen) { 179 TEST_F(BrowserWindowLayoutTest, TestAvatarButtonFullscreen) {
180 [layout setInAnyFullscreen:YES]; 180 [layout setInAnyFullscreen:YES];
181 [layout setFullscreenButtonFrame:NSZeroRect]; 181 [layout setFullscreenButtonFrame:NSZeroRect];
182 182
183 [layout setShouldUseNewAvatar:YES]; 183 [layout setShouldUseNewAvatar:YES];
184 chrome::TabStripLayout tabStripLayout = [layout computeLayout].tabStripLayout; 184 chrome::TabStripLayout tabStripLayout = [layout computeLayout].tabStripLayout;
185 EXPECT_EQ(NSWidth(tabStripLayout.frame) - NSMinX(tabStripLayout.avatarFrame), 185 EXPECT_EQ(NSWidth(tabStripLayout.frame) - NSMinX(tabStripLayout.avatarFrame),
186 tabStripLayout.rightIndent); 186 tabStripLayout.trailingIndent);
187 187
188 [layout setShouldUseNewAvatar:NO]; 188 [layout setShouldUseNewAvatar:NO];
189 tabStripLayout = [layout computeLayout].tabStripLayout; 189 tabStripLayout = [layout computeLayout].tabStripLayout;
190 EXPECT_EQ(NSWidth(tabStripLayout.frame) - NSMinX(tabStripLayout.avatarFrame), 190 EXPECT_EQ(NSWidth(tabStripLayout.frame) - NSMinX(tabStripLayout.avatarFrame),
191 tabStripLayout.rightIndent); 191 tabStripLayout.trailingIndent);
192 } 192 }
193 193
194 TEST_F(BrowserWindowLayoutTest, TestInfobarLayoutWithoutToolbarOrLocationBar) { 194 TEST_F(BrowserWindowLayoutTest, TestInfobarLayoutWithoutToolbarOrLocationBar) {
195 [layout setHasTabStrip:NO]; 195 [layout setHasTabStrip:NO];
196 [layout setHasToolbar:NO]; 196 [layout setHasToolbar:NO];
197 [layout setHasLocationBar:NO]; 197 [layout setHasLocationBar:NO];
198 [layout setBookmarkBarHidden:YES]; 198 [layout setBookmarkBarHidden:YES];
199 [layout setHasDownloadShelf:NO]; 199 [layout setHasDownloadShelf:NO];
200 200
201 chrome::LayoutOutput output = [layout computeLayout]; 201 chrome::LayoutOutput output = [layout computeLayout];
202 202
203 EXPECT_NSEQ(NSMakeRect(0, 528, 600, 72), output.infoBarFrame); 203 EXPECT_NSEQ(NSMakeRect(0, 528, 600, 72), output.infoBarFrame);
204 } 204 }
205 205
206 // Tests that the avatar button is not aligned on the half pixel. 206 // Tests that the avatar button is not aligned on the half pixel.
207 TEST_F(BrowserWindowLayoutTest, TestAvatarButtonPixelAlignment) { 207 TEST_F(BrowserWindowLayoutTest, TestAvatarButtonPixelAlignment) {
208 [layout setAvatarSize:NSMakeSize(28, 28)]; 208 [layout setAvatarSize:NSMakeSize(28, 28)];
209 209
210 chrome::LayoutOutput output = [layout computeLayout]; 210 chrome::LayoutOutput output = [layout computeLayout];
211 211
212 EXPECT_NSEQ(NSMakeRect(537, 589, 28, 28), output.tabStripLayout.avatarFrame); 212 EXPECT_NSEQ(NSMakeRect(537, 589, 28, 28), output.tabStripLayout.avatarFrame);
213 } 213 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_layout.mm ('k') | chrome/browser/ui/cocoa/tabs/tab_strip_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698