opaque_browser_frame_view_layout_unittest.cc revision 010d83a9304c5a91596085d917d248abff47903a
1// Copyright 2013 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" 6 7#include "base/basictypes.h" 8#include "base/command_line.h" 9#include "base/strings/utf_string_conversions.h" 10#include "chrome/browser/ui/views/profiles/avatar_label.h" 11#include "chrome/browser/ui/views/profiles/avatar_menu_button.h" 12#include "chrome/browser/ui/views/tab_icon_view.h" 13#include "chrome/browser/ui/views/tabs/tab.h" 14#include "chrome/common/chrome_switches.h" 15#include "ui/gfx/image/image_skia.h" 16#include "ui/gfx/image/image_skia_rep.h" 17#include "ui/gfx/text_constants.h" 18#include "ui/views/controls/button/image_button.h" 19#include "ui/views/controls/button/menu_button.h" 20#include "ui/views/controls/label.h" 21#include "ui/views/test/views_test_base.h" 22 23using views::Widget; 24 25namespace { 26 27const int kWidth = 500; 28 29class TestLayoutDelegate : public OpaqueBrowserFrameViewLayoutDelegate { 30 public: 31 enum WindowState { 32 STATE_NORMAL, 33 STATE_MAXIMIZED, 34 STATE_MINIMIZED, 35 STATE_FULLSCREEN 36 }; 37 38 TestLayoutDelegate() 39 : show_avatar_(false), 40 show_caption_buttons_(true), 41 window_state_(STATE_NORMAL) { 42 } 43 44 virtual ~TestLayoutDelegate() {} 45 46 void SetWindowTitle(const base::string16& title) { 47 window_title_ = title; 48 } 49 50 void SetShouldShowAvatar(bool show_avatar) { 51 show_avatar_ = show_avatar; 52 } 53 54 void SetShouldShowCaptionButtons(bool show_caption_buttons) { 55 show_caption_buttons_ = show_caption_buttons; 56 } 57 58 void SetWindowState(WindowState state) { 59 window_state_ = state; 60 } 61 62 // OpaqueBrowserFrameViewLayoutDelegate overrides: 63 64 virtual bool ShouldShowWindowIcon() const OVERRIDE { 65 return !window_title_.empty(); 66 } 67 68 virtual bool ShouldShowWindowTitle() const OVERRIDE { 69 return !window_title_.empty(); 70 } 71 72 virtual base::string16 GetWindowTitle() const OVERRIDE { 73 return window_title_; 74 } 75 76 virtual int GetIconSize() const OVERRIDE { 77 // The value on linux_aura and non-aura windows. 78 return 17; 79 } 80 81 virtual bool ShouldLeaveOffsetNearTopBorder() const OVERRIDE { 82 return !IsMaximized(); 83 } 84 85 virtual gfx::Size GetBrowserViewMinimumSize() const OVERRIDE { 86 // Taken from a calculation in BrowserViewLayout. 87 return gfx::Size(168, 64); 88 } 89 90 virtual bool ShouldShowCaptionButtons() const OVERRIDE { 91 return show_caption_buttons_; 92 } 93 94 virtual bool ShouldShowAvatar() const OVERRIDE { 95 return show_avatar_; 96 } 97 98 virtual bool IsRegularOrGuestSession() const OVERRIDE { 99 return true; 100 } 101 102 virtual gfx::ImageSkia GetOTRAvatarIcon() const OVERRIDE { 103 // The calculations depend on the size of the OTR resource, and chromeos 104 // uses a different sized image, so hard code the size of the current 105 // windows/linux one. 106 gfx::ImageSkiaRep rep(gfx::Size(40, 29), 1.0f); 107 gfx::ImageSkia image(rep); 108 return image; 109 } 110 111 virtual bool IsMaximized() const OVERRIDE { 112 return window_state_ == STATE_MAXIMIZED; 113 } 114 115 virtual bool IsMinimized() const OVERRIDE { 116 return window_state_ == STATE_MINIMIZED; 117 } 118 119 virtual bool IsFullscreen() const OVERRIDE { 120 return window_state_ == STATE_FULLSCREEN; 121 } 122 123 virtual bool IsTabStripVisible() const OVERRIDE { 124 return window_title_.empty(); 125 } 126 127 virtual int GetTabStripHeight() const OVERRIDE { 128 return IsTabStripVisible() ? Tab::GetMinimumUnselectedSize().height() : 0; 129 } 130 131 virtual gfx::Size GetTabstripPreferredSize() const OVERRIDE { 132 // Measured from Tabstrip::GetPreferredSize(). 133 return IsTabStripVisible() ? gfx::Size(78, 29) : gfx::Size(0, 0); 134 } 135 136 private: 137 base::string16 window_title_; 138 bool show_avatar_; 139 bool show_caption_buttons_; 140 WindowState window_state_; 141 142 DISALLOW_COPY_AND_ASSIGN(TestLayoutDelegate); 143}; 144 145} // namespace 146 147class OpaqueBrowserFrameViewLayoutTest : public views::ViewsTestBase { 148 public: 149 OpaqueBrowserFrameViewLayoutTest() {} 150 virtual ~OpaqueBrowserFrameViewLayoutTest() {} 151 152 virtual void SetUp() OVERRIDE { 153 views::ViewsTestBase::SetUp(); 154 155 delegate_.reset(new TestLayoutDelegate); 156 layout_manager_ = new OpaqueBrowserFrameViewLayout(delegate_.get()); 157 layout_manager_->set_extra_caption_y(0); 158 layout_manager_->set_window_caption_spacing(0); 159 widget_ = new Widget; 160 widget_->Init(CreateParams(Widget::InitParams::TYPE_POPUP)); 161 root_view_ = widget_->GetRootView(); 162 root_view_->SetSize(gfx::Size(kWidth, kWidth)); 163 root_view_->SetLayoutManager(layout_manager_); 164 165 // Add the caption buttons. We use fake images because we're modeling the 166 // Windows assets here, while the linux version uses differently sized 167 // assets. 168 // 169 // TODO(erg): In a follow up patch, separate these sizes out into virtual 170 // accessors so we can test both the windows and linux behaviours once we 171 // start modifying the code. 172 minimize_button_ = InitWindowCaptionButton( 173 VIEW_ID_MINIMIZE_BUTTON, gfx::Size(26, 18)); 174 maximize_button_ = InitWindowCaptionButton( 175 VIEW_ID_MAXIMIZE_BUTTON, gfx::Size(25, 18)); 176 restore_button_ = InitWindowCaptionButton( 177 VIEW_ID_RESTORE_BUTTON, gfx::Size(25, 18)); 178 close_button_ = InitWindowCaptionButton( 179 VIEW_ID_CLOSE_BUTTON, gfx::Size(43, 18)); 180 } 181 182 virtual void TearDown() OVERRIDE { 183 widget_->CloseNow(); 184 185 views::ViewsTestBase::TearDown(); 186 } 187 188 protected: 189 views::ImageButton* InitWindowCaptionButton(ViewID view_id, 190 const gfx::Size& size) { 191 views::ImageButton* button = new views::ImageButton(NULL); 192 gfx::ImageSkiaRep rep(size, 1.0f); 193 gfx::ImageSkia image(rep); 194 button->SetImage(views::CustomButton::STATE_NORMAL, &image); 195 button->set_id(view_id); 196 root_view_->AddChildView(button); 197 return button; 198 } 199 200 void AddWindowTitleIcons() { 201 tab_icon_view_ = new TabIconView(NULL, NULL); 202 tab_icon_view_->set_is_light(true); 203 tab_icon_view_->set_id(VIEW_ID_WINDOW_ICON); 204 root_view_->AddChildView(tab_icon_view_); 205 206 window_title_ = new views::Label(delegate_->GetWindowTitle()); 207 window_title_->SetVisible(delegate_->ShouldShowWindowTitle()); 208 window_title_->SetEnabledColor(SK_ColorWHITE); 209 window_title_->SetBackgroundColor(0x00000000); 210 window_title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 211 window_title_->set_id(VIEW_ID_WINDOW_TITLE); 212 root_view_->AddChildView(window_title_); 213 } 214 215 void AddAvatarButton() { 216 menu_button_ = new AvatarMenuButton(NULL, false); 217 menu_button_->set_id(VIEW_ID_AVATAR_BUTTON); 218 delegate_->SetShouldShowAvatar(true); 219 root_view_->AddChildView(menu_button_); 220 } 221 222 void AddAvatarLabel() { 223 avatar_label_ = new AvatarLabel(NULL); 224 avatar_label_->set_id(VIEW_ID_AVATAR_LABEL); 225 root_view_->AddChildView(avatar_label_); 226 227 // The avatar label should only be used together with the avatar button. 228 AddAvatarButton(); 229 } 230 231 void AddNewAvatarButton() { 232 new_avatar_button_ = 233 new views::MenuButton(NULL, base::string16(), NULL, false); 234 new_avatar_button_->set_id(VIEW_ID_NEW_AVATAR_BUTTON); 235 root_view_->AddChildView(new_avatar_button_); 236 } 237 238 void ExpectBasicWindowBounds() { 239 EXPECT_EQ("428,1 25x18", maximize_button_->bounds().ToString()); 240 EXPECT_EQ("402,1 26x18", minimize_button_->bounds().ToString()); 241 EXPECT_EQ("0,0 0x0", restore_button_->bounds().ToString()); 242 EXPECT_EQ("453,1 43x18", close_button_->bounds().ToString()); 243 } 244 245 Widget* widget_; 246 views::View* root_view_; 247 OpaqueBrowserFrameViewLayout* layout_manager_; 248 scoped_ptr<TestLayoutDelegate> delegate_; 249 250 // Widgets: 251 views::ImageButton* minimize_button_; 252 views::ImageButton* maximize_button_; 253 views::ImageButton* restore_button_; 254 views::ImageButton* close_button_; 255 256 TabIconView* tab_icon_view_; 257 views::Label* window_title_; 258 259 AvatarLabel* avatar_label_; 260 AvatarMenuButton* menu_button_; 261 views::MenuButton* new_avatar_button_; 262 263 DISALLOW_COPY_AND_ASSIGN(OpaqueBrowserFrameViewLayoutTest); 264}; 265 266TEST_F(OpaqueBrowserFrameViewLayoutTest, BasicWindow) { 267 // Tests the layout of a default chrome window with no avatars, no window 268 // titles, and a tabstrip. 269 root_view_->Layout(); 270 271 ExpectBasicWindowBounds(); 272 273 // After some visual inspection, it really does look like the tabstrip is 274 // initally positioned out of our view. 275 EXPECT_EQ("-1,13 398x29", 276 layout_manager_->GetBoundsForTabStrip( 277 delegate_->GetTabstripPreferredSize(), kWidth).ToString()); 278 EXPECT_EQ("261x73", layout_manager_->GetMinimumSize(kWidth).ToString()); 279 280 // A normal window with no window icon still produces icon bounds for 281 // Windows, which has a hidden icon that a user can double click on to close 282 // the window. 283 EXPECT_EQ("6,4 17x17", layout_manager_->IconBounds().ToString()); 284} 285 286TEST_F(OpaqueBrowserFrameViewLayoutTest, BasicWindowMaximized) { 287 // Tests the layout of a default chrome window with no avatars, no window 288 // titles, and a tabstrip, but maximized this time. 289 delegate_->SetWindowState(TestLayoutDelegate::STATE_MAXIMIZED); 290 root_view_->Layout(); 291 292 // Note how the bounds start at the exact top of the window while maximized 293 // while they start 1 pixel below when unmaximized. 294 EXPECT_EQ("0,0 0x0", maximize_button_->bounds().ToString()); 295 EXPECT_EQ("403,0 26x18", minimize_button_->bounds().ToString()); 296 EXPECT_EQ("429,0 25x18", restore_button_->bounds().ToString()); 297 EXPECT_EQ("454,0 46x18", close_button_->bounds().ToString()); 298 299 EXPECT_EQ("-5,-3 392x29", 300 layout_manager_->GetBoundsForTabStrip( 301 delegate_->GetTabstripPreferredSize(), kWidth).ToString()); 302 EXPECT_EQ("262x61", layout_manager_->GetMinimumSize(kWidth).ToString()); 303 304 // In the maximized case, OpaqueBrowserFrameView::NonClientHitTest() uses 305 // this rect, extended to the top left corner of the window. 306 EXPECT_EQ("2,0 17x17", layout_manager_->IconBounds().ToString()); 307} 308 309TEST_F(OpaqueBrowserFrameViewLayoutTest, MaximizedWithYOffset) { 310 // Tests the layout of a basic chrome window with the caption buttons slightly 311 // offset from the top of the screen (as they are on Linux). 312 layout_manager_->set_extra_caption_y(2); 313 delegate_->SetWindowState(TestLayoutDelegate::STATE_MAXIMIZED); 314 root_view_->Layout(); 315 316 // Note how the bounds start at the exact top of the window, DESPITE the 317 // caption Y offset of 2. This ensures that we obey Fitts' Law (the buttons 318 // are clickable on the top edge of the screen). However, the buttons are 2 319 // pixels taller, so the images appear to be offset by 2 pixels. 320 EXPECT_EQ("0,0 0x0", maximize_button_->bounds().ToString()); 321 EXPECT_EQ("403,0 26x20", minimize_button_->bounds().ToString()); 322 EXPECT_EQ("429,0 25x20", restore_button_->bounds().ToString()); 323 EXPECT_EQ("454,0 46x20", close_button_->bounds().ToString()); 324 325 EXPECT_EQ("-5,-3 392x29", 326 layout_manager_->GetBoundsForTabStrip( 327 delegate_->GetTabstripPreferredSize(), kWidth).ToString()); 328 EXPECT_EQ("262x61", layout_manager_->GetMinimumSize(kWidth).ToString()); 329 330 // In the maximized case, OpaqueBrowserFrameView::NonClientHitTest() uses 331 // this rect, extended to the top left corner of the window. 332 EXPECT_EQ("2,0 17x17", layout_manager_->IconBounds().ToString()); 333} 334 335TEST_F(OpaqueBrowserFrameViewLayoutTest, WindowButtonsOnLeft) { 336 // Tests the layout of a chrome window with caption buttons on the left. 337 std::vector<views::FrameButton> leading_buttons; 338 std::vector<views::FrameButton> trailing_buttons; 339 leading_buttons.push_back(views::FRAME_BUTTON_CLOSE); 340 leading_buttons.push_back(views::FRAME_BUTTON_MINIMIZE); 341 leading_buttons.push_back(views::FRAME_BUTTON_MAXIMIZE); 342 layout_manager_->SetButtonOrdering(leading_buttons, trailing_buttons); 343 root_view_->Layout(); 344 345 EXPECT_EQ("73,1 25x18", maximize_button_->bounds().ToString()); 346 EXPECT_EQ("47,1 26x18", minimize_button_->bounds().ToString()); 347 EXPECT_EQ("0,0 0x0", restore_button_->bounds().ToString()); 348 EXPECT_EQ("4,1 43x18", close_button_->bounds().ToString()); 349 350 EXPECT_EQ("93,13 398x29", 351 layout_manager_->GetBoundsForTabStrip( 352 delegate_->GetTabstripPreferredSize(), kWidth).ToString()); 353 EXPECT_EQ("261x73", layout_manager_->GetMinimumSize(kWidth).ToString()); 354 355 // If the buttons are on the left, there should be no hidden icon for the user 356 // to double click. 357 EXPECT_EQ("0,0 0x0", layout_manager_->IconBounds().ToString()); 358} 359 360TEST_F(OpaqueBrowserFrameViewLayoutTest, WithoutCaptionButtons) { 361 // Tests the layout of a default chrome window with no caption buttons (which 362 // should force the tab strip to be condensed). 363 delegate_->SetShouldShowCaptionButtons(false); 364 root_view_->Layout(); 365 366 EXPECT_EQ("0,0 0x0", maximize_button_->bounds().ToString()); 367 EXPECT_EQ("0,0 0x0", minimize_button_->bounds().ToString()); 368 EXPECT_EQ("0,0 0x0", restore_button_->bounds().ToString()); 369 EXPECT_EQ("0,0 0x0", close_button_->bounds().ToString()); 370 371 EXPECT_EQ("-5,-3 500x29", 372 layout_manager_->GetBoundsForTabStrip( 373 delegate_->GetTabstripPreferredSize(), kWidth).ToString()); 374 EXPECT_EQ("251x61", layout_manager_->GetMinimumSize(kWidth).ToString()); 375 376 // A normal window with no window icon still produces icon bounds for 377 // Windows, which has a hidden icon that a user can double click on to close 378 // the window. 379 EXPECT_EQ("2,0 17x17", layout_manager_->IconBounds().ToString()); 380} 381 382TEST_F(OpaqueBrowserFrameViewLayoutTest, MaximizedWithoutCaptionButtons) { 383 // Tests the layout of a maximized chrome window with no caption buttons. 384 delegate_->SetWindowState(TestLayoutDelegate::STATE_MAXIMIZED); 385 delegate_->SetShouldShowCaptionButtons(false); 386 root_view_->Layout(); 387 388 EXPECT_EQ("0,0 0x0", maximize_button_->bounds().ToString()); 389 EXPECT_EQ("0,0 0x0", minimize_button_->bounds().ToString()); 390 EXPECT_EQ("0,0 0x0", restore_button_->bounds().ToString()); 391 EXPECT_EQ("0,0 0x0", close_button_->bounds().ToString()); 392 393 EXPECT_EQ("-5,-3 500x29", 394 layout_manager_->GetBoundsForTabStrip( 395 delegate_->GetTabstripPreferredSize(), kWidth).ToString()); 396 EXPECT_EQ("251x61", layout_manager_->GetMinimumSize(kWidth).ToString()); 397 398 // In the maximized case, OpaqueBrowserFrameView::NonClientHitTest() uses 399 // this rect, extended to the top left corner of the window. 400 EXPECT_EQ("2,0 17x17", layout_manager_->IconBounds().ToString()); 401} 402 403TEST_F(OpaqueBrowserFrameViewLayoutTest, WithWindowTitleAndIcon) { 404 // Tests the layout of pop up windows. 405 delegate_->SetWindowTitle(base::ASCIIToUTF16("Window Title")); 406 AddWindowTitleIcons(); 407 root_view_->Layout(); 408 409 // We should have the right hand side should match the BasicWindow case. 410 ExpectBasicWindowBounds(); 411 412 // Check the location of the tab icon and window title. 413 EXPECT_EQ("6,3 17x17", tab_icon_view_->bounds().ToString()); 414 EXPECT_EQ("27,3 370x17", window_title_->bounds().ToString()); 415} 416 417TEST_F(OpaqueBrowserFrameViewLayoutTest, WindowWithAvatar) { 418 // Tests a normal tabstrip window with an avatar icon. 419 AddAvatarButton(); 420 root_view_->Layout(); 421 422 ExpectBasicWindowBounds(); 423 424 // Check the location of the avatar 425 EXPECT_EQ("7,11 40x29", menu_button_->bounds().ToString()); 426 EXPECT_EQ("45,13 352x29", 427 layout_manager_->GetBoundsForTabStrip( 428 delegate_->GetTabstripPreferredSize(), kWidth).ToString()); 429 EXPECT_EQ("261x73", layout_manager_->GetMinimumSize(kWidth).ToString()); 430} 431 432TEST_F(OpaqueBrowserFrameViewLayoutTest, WindowWithAvatarWithButtonsOnLeft) { 433 // Tests the layout of a chrome window with an avatar icon and caption buttons 434 // on the left. The avatar icon should therefore be on the right. 435 // AddAvatarLabel() also adds the avatar button. 436 AddAvatarLabel(); 437 std::vector<views::FrameButton> leading_buttons; 438 std::vector<views::FrameButton> trailing_buttons; 439 leading_buttons.push_back(views::FRAME_BUTTON_CLOSE); 440 leading_buttons.push_back(views::FRAME_BUTTON_MINIMIZE); 441 leading_buttons.push_back(views::FRAME_BUTTON_MAXIMIZE); 442 layout_manager_->SetButtonOrdering(leading_buttons, trailing_buttons); 443 root_view_->Layout(); 444 445 EXPECT_EQ("73,1 25x18", maximize_button_->bounds().ToString()); 446 EXPECT_EQ("47,1 26x18", minimize_button_->bounds().ToString()); 447 EXPECT_EQ("0,0 0x0", restore_button_->bounds().ToString()); 448 EXPECT_EQ("4,1 43x18", close_button_->bounds().ToString()); 449 450 // Check the location of the avatar 451 EXPECT_EQ("454,11 40x29", menu_button_->bounds().ToString()); 452 453 // Check the tab strip bounds. 454 gfx::Rect tab_strip_bounds = layout_manager_->GetBoundsForTabStrip( 455 delegate_->GetTabstripPreferredSize(), kWidth); 456 EXPECT_GT(tab_strip_bounds.x(), maximize_button_->bounds().x()); 457 EXPECT_GT(maximize_button_->bounds().right(), tab_strip_bounds.x()); 458 EXPECT_EQ(13, tab_strip_bounds.y()); 459 EXPECT_EQ(29, tab_strip_bounds.height()); 460 EXPECT_GT(avatar_label_->bounds().x(), tab_strip_bounds.right()); 461 EXPECT_EQ("261x73", layout_manager_->GetMinimumSize(kWidth).ToString()); 462 463 // Check the relative location of the avatar label to the avatar. The right 464 // end of the avatar label should be slightly to the right of the right end of 465 // the avatar icon. 466 EXPECT_GT(avatar_label_->bounds().right(), menu_button_->bounds().right()); 467 EXPECT_GT(menu_button_->bounds().x(), avatar_label_->bounds().x()); 468 EXPECT_GT(menu_button_->bounds().bottom(), 469 avatar_label_->bounds().bottom()); 470 EXPECT_GT(avatar_label_->bounds().y(), menu_button_->bounds().y()); 471 472 // This means that the menu will pop out facing the left (if it were to face 473 // the right, it would go outside the window frame and be clipped). 474 EXPECT_TRUE(menu_button_->button_on_right()); 475 476 // If the buttons are on the left, there should be no hidden icon for the user 477 // to double click. 478 EXPECT_EQ("0,0 0x0", layout_manager_->IconBounds().ToString()); 479} 480 481TEST_F(OpaqueBrowserFrameViewLayoutTest, 482 WindowWithAvatarWithoutCaptionButtonsOnLeft) { 483 // Tests the layout of a chrome window with an avatar icon and no caption 484 // buttons. However, the caption buttons *would* be on the left if they 485 // weren't hidden, and therefore, the avatar icon should be on the right. 486 // The lack of caption buttons should force the tab strip to be condensed. 487 AddAvatarButton(); 488 std::vector<views::FrameButton> leading_buttons; 489 std::vector<views::FrameButton> trailing_buttons; 490 leading_buttons.push_back(views::FRAME_BUTTON_CLOSE); 491 leading_buttons.push_back(views::FRAME_BUTTON_MINIMIZE); 492 leading_buttons.push_back(views::FRAME_BUTTON_MAXIMIZE); 493 layout_manager_->SetButtonOrdering(leading_buttons, trailing_buttons); 494 delegate_->SetShouldShowCaptionButtons(false); 495 root_view_->Layout(); 496 497 EXPECT_EQ("0,0 0x0", maximize_button_->bounds().ToString()); 498 EXPECT_EQ("0,0 0x0", minimize_button_->bounds().ToString()); 499 EXPECT_EQ("0,0 0x0", restore_button_->bounds().ToString()); 500 EXPECT_EQ("0,0 0x0", close_button_->bounds().ToString()); 501 502 // Check the location of the avatar 503 EXPECT_EQ("458,0 40x24", menu_button_->bounds().ToString()); 504 EXPECT_EQ("-5,-3 458x29", 505 layout_manager_->GetBoundsForTabStrip( 506 delegate_->GetTabstripPreferredSize(), kWidth).ToString()); 507 EXPECT_EQ("251x61", layout_manager_->GetMinimumSize(kWidth).ToString()); 508 509 // A normal window with no window icon still produces icon bounds for 510 // Windows, which has a hidden icon that a user can double click on to close 511 // the window. 512 EXPECT_EQ("2,0 17x17", layout_manager_->IconBounds().ToString()); 513} 514 515TEST_F(OpaqueBrowserFrameViewLayoutTest, WindowWithNewAvatar) { 516 CommandLine::ForCurrentProcess()->AppendSwitch( 517 switches::kNewProfileManagement); 518 519 // Tests a normal tabstrip window with the new style avatar icon. 520 AddNewAvatarButton(); 521 root_view_->Layout(); 522 523 ExpectBasicWindowBounds(); 524 525 // Check the location of the caption button 526 EXPECT_EQ("385,1 12x20", new_avatar_button_->bounds().ToString()); 527 // The basic window bounds are (-1, 13 398x29). There should not be an icon 528 // avatar in the left, and the new avatar button has an offset of 5 to its 529 // next control. 530 EXPECT_EQ("-1,13 381x29", 531 layout_manager_->GetBoundsForTabStrip( 532 delegate_->GetTabstripPreferredSize(), kWidth).ToString()); 533 EXPECT_EQ("261x73", layout_manager_->GetMinimumSize(kWidth).ToString()); 534} 535 536TEST_F(OpaqueBrowserFrameViewLayoutTest, WindowWithAvatarLabelAndButtonOnLeft) { 537 AddAvatarLabel(); 538 root_view_->Layout(); 539 540 ExpectBasicWindowBounds(); 541 542 // Check the location of the avatar label relative to the avatar button if 543 // both are displayed on the left side. 544 // The label height and width depends on the font size and the text displayed. 545 // This may possibly change, so we don't test it here. 546 EXPECT_EQ(menu_button_->bounds().x() - 2, avatar_label_->bounds().x()); 547 EXPECT_EQ( 548 menu_button_->bounds().bottom() - 3 - avatar_label_->bounds().height(), 549 avatar_label_->bounds().y()); 550} 551