| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" | 5 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/ui/views/avatar_label.h" | 10 #include "chrome/browser/ui/views/avatar_label.h" |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 layout_manager_->GetBoundsForTabStrip( | 355 layout_manager_->GetBoundsForTabStrip( |
| 356 delegate_->GetTabstripPreferredSize(), kWidth).ToString()); | 356 delegate_->GetTabstripPreferredSize(), kWidth).ToString()); |
| 357 EXPECT_EQ("261x73", layout_manager_->GetMinimumSize(kWidth).ToString()); | 357 EXPECT_EQ("261x73", layout_manager_->GetMinimumSize(kWidth).ToString()); |
| 358 | 358 |
| 359 // If the buttons are on the left, there should be no hidden icon for the user | 359 // If the buttons are on the left, there should be no hidden icon for the user |
| 360 // to double click. | 360 // to double click. |
| 361 EXPECT_EQ("0,0 0x0", layout_manager_->IconBounds().ToString()); | 361 EXPECT_EQ("0,0 0x0", layout_manager_->IconBounds().ToString()); |
| 362 } | 362 } |
| 363 | 363 |
| 364 TEST_F(OpaqueBrowserFrameViewLayoutTest, WithoutCaptionButtons) { | 364 TEST_F(OpaqueBrowserFrameViewLayoutTest, WithoutCaptionButtons) { |
| 365 // Tests the layout of a default chrome window with no caption buttons. | 365 // Tests the layout of a default chrome window with no caption buttons (which |
| 366 // should force the tab strip to be condensed). |
| 366 delegate_->SetShouldShowCaptionButtons(false); | 367 delegate_->SetShouldShowCaptionButtons(false); |
| 367 root_view_->Layout(); | 368 root_view_->Layout(); |
| 368 | 369 |
| 369 EXPECT_EQ("0,0 0x0", maximize_button_->bounds().ToString()); | 370 EXPECT_EQ("0,0 0x0", maximize_button_->bounds().ToString()); |
| 370 EXPECT_EQ("0,0 0x0", minimize_button_->bounds().ToString()); | 371 EXPECT_EQ("0,0 0x0", minimize_button_->bounds().ToString()); |
| 371 EXPECT_EQ("0,0 0x0", restore_button_->bounds().ToString()); | 372 EXPECT_EQ("0,0 0x0", restore_button_->bounds().ToString()); |
| 372 EXPECT_EQ("0,0 0x0", close_button_->bounds().ToString()); | 373 EXPECT_EQ("0,0 0x0", close_button_->bounds().ToString()); |
| 373 | 374 |
| 374 EXPECT_EQ("-1,13 492x29", | 375 EXPECT_EQ("-5,-3 500x29", |
| 375 layout_manager_->GetBoundsForTabStrip( | 376 layout_manager_->GetBoundsForTabStrip( |
| 376 delegate_->GetTabstripPreferredSize(), kWidth).ToString()); | 377 delegate_->GetTabstripPreferredSize(), kWidth).ToString()); |
| 377 EXPECT_EQ("261x73", layout_manager_->GetMinimumSize(kWidth).ToString()); | 378 EXPECT_EQ("251x61", layout_manager_->GetMinimumSize(kWidth).ToString()); |
| 378 | 379 |
| 379 // A normal window with no window icon still produces icon bounds for | 380 // A normal window with no window icon still produces icon bounds for |
| 380 // Windows, which has a hidden icon that a user can double click on to close | 381 // Windows, which has a hidden icon that a user can double click on to close |
| 381 // the window. | 382 // the window. |
| 382 EXPECT_EQ("6,4 17x17", layout_manager_->IconBounds().ToString()); | 383 EXPECT_EQ("2,0 17x17", layout_manager_->IconBounds().ToString()); |
| 383 } | 384 } |
| 384 | 385 |
| 385 TEST_F(OpaqueBrowserFrameViewLayoutTest, MaximizedWithoutCaptionButtons) { | 386 TEST_F(OpaqueBrowserFrameViewLayoutTest, MaximizedWithoutCaptionButtons) { |
| 386 // Tests the layout of a maximized chrome window with no caption buttons. | 387 // Tests the layout of a maximized chrome window with no caption buttons. |
| 387 delegate_->SetWindowState(TestLayoutDelegate::STATE_MAXIMIZED); | 388 delegate_->SetWindowState(TestLayoutDelegate::STATE_MAXIMIZED); |
| 388 delegate_->SetShouldShowCaptionButtons(false); | 389 delegate_->SetShouldShowCaptionButtons(false); |
| 389 root_view_->Layout(); | 390 root_view_->Layout(); |
| 390 | 391 |
| 391 EXPECT_EQ("0,0 0x0", maximize_button_->bounds().ToString()); | 392 EXPECT_EQ("0,0 0x0", maximize_button_->bounds().ToString()); |
| 392 EXPECT_EQ("0,0 0x0", minimize_button_->bounds().ToString()); | 393 EXPECT_EQ("0,0 0x0", minimize_button_->bounds().ToString()); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 // If the buttons are on the left, there should be no hidden icon for the user | 480 // If the buttons are on the left, there should be no hidden icon for the user |
| 480 // to double click. | 481 // to double click. |
| 481 EXPECT_EQ("0,0 0x0", layout_manager_->IconBounds().ToString()); | 482 EXPECT_EQ("0,0 0x0", layout_manager_->IconBounds().ToString()); |
| 482 } | 483 } |
| 483 | 484 |
| 484 TEST_F(OpaqueBrowserFrameViewLayoutTest, | 485 TEST_F(OpaqueBrowserFrameViewLayoutTest, |
| 485 WindowWithAvatarWithoutCaptionButtonsOnLeft) { | 486 WindowWithAvatarWithoutCaptionButtonsOnLeft) { |
| 486 // Tests the layout of a chrome window with an avatar icon and no caption | 487 // Tests the layout of a chrome window with an avatar icon and no caption |
| 487 // buttons. However, the caption buttons *would* be on the left if they | 488 // buttons. However, the caption buttons *would* be on the left if they |
| 488 // weren't hidden, and therefore, the avatar icon should be on the right. | 489 // weren't hidden, and therefore, the avatar icon should be on the right. |
| 490 // The lack of caption buttons should force the tab strip to be condensed. |
| 489 AddAvatarButton(); | 491 AddAvatarButton(); |
| 490 std::vector<views::FrameButton> leading_buttons; | 492 std::vector<views::FrameButton> leading_buttons; |
| 491 std::vector<views::FrameButton> trailing_buttons; | 493 std::vector<views::FrameButton> trailing_buttons; |
| 492 leading_buttons.push_back(views::FRAME_BUTTON_CLOSE); | 494 leading_buttons.push_back(views::FRAME_BUTTON_CLOSE); |
| 493 leading_buttons.push_back(views::FRAME_BUTTON_MINIMIZE); | 495 leading_buttons.push_back(views::FRAME_BUTTON_MINIMIZE); |
| 494 leading_buttons.push_back(views::FRAME_BUTTON_MAXIMIZE); | 496 leading_buttons.push_back(views::FRAME_BUTTON_MAXIMIZE); |
| 495 layout_manager_->SetButtonOrdering(leading_buttons, trailing_buttons); | 497 layout_manager_->SetButtonOrdering(leading_buttons, trailing_buttons); |
| 496 delegate_->SetShouldShowCaptionButtons(false); | 498 delegate_->SetShouldShowCaptionButtons(false); |
| 497 root_view_->Layout(); | 499 root_view_->Layout(); |
| 498 | 500 |
| 499 EXPECT_EQ("0,0 0x0", maximize_button_->bounds().ToString()); | 501 EXPECT_EQ("0,0 0x0", maximize_button_->bounds().ToString()); |
| 500 EXPECT_EQ("0,0 0x0", minimize_button_->bounds().ToString()); | 502 EXPECT_EQ("0,0 0x0", minimize_button_->bounds().ToString()); |
| 501 EXPECT_EQ("0,0 0x0", restore_button_->bounds().ToString()); | 503 EXPECT_EQ("0,0 0x0", restore_button_->bounds().ToString()); |
| 502 EXPECT_EQ("0,0 0x0", close_button_->bounds().ToString()); | 504 EXPECT_EQ("0,0 0x0", close_button_->bounds().ToString()); |
| 503 | 505 |
| 504 // Check the location of the avatar | 506 // Check the location of the avatar |
| 505 EXPECT_EQ("454,11 40x29", menu_button_->bounds().ToString()); | 507 EXPECT_EQ("458,0 40x24", menu_button_->bounds().ToString()); |
| 506 EXPECT_EQ("-1,13 450x29", | 508 EXPECT_EQ("-5,-3 458x29", |
| 507 layout_manager_->GetBoundsForTabStrip( | 509 layout_manager_->GetBoundsForTabStrip( |
| 508 delegate_->GetTabstripPreferredSize(), kWidth).ToString()); | 510 delegate_->GetTabstripPreferredSize(), kWidth).ToString()); |
| 509 EXPECT_EQ("261x73", layout_manager_->GetMinimumSize(kWidth).ToString()); | 511 EXPECT_EQ("251x61", layout_manager_->GetMinimumSize(kWidth).ToString()); |
| 510 | 512 |
| 511 // A normal window with no window icon still produces icon bounds for | 513 // A normal window with no window icon still produces icon bounds for |
| 512 // Windows, which has a hidden icon that a user can double click on to close | 514 // Windows, which has a hidden icon that a user can double click on to close |
| 513 // the window. | 515 // the window. |
| 514 EXPECT_EQ("6,4 17x17", layout_manager_->IconBounds().ToString()); | 516 EXPECT_EQ("2,0 17x17", layout_manager_->IconBounds().ToString()); |
| 515 } | 517 } |
| 516 | 518 |
| 517 TEST_F(OpaqueBrowserFrameViewLayoutTest, WindowWithNewAvatar) { | 519 TEST_F(OpaqueBrowserFrameViewLayoutTest, WindowWithNewAvatar) { |
| 518 CommandLine::ForCurrentProcess()->AppendSwitch( | 520 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 519 switches::kNewProfileManagement); | 521 switches::kNewProfileManagement); |
| 520 | 522 |
| 521 // Tests a normal tabstrip window with the new style avatar icon. | 523 // Tests a normal tabstrip window with the new style avatar icon. |
| 522 AddNewAvatarButton(); | 524 AddNewAvatarButton(); |
| 523 root_view_->Layout(); | 525 root_view_->Layout(); |
| 524 | 526 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 543 | 545 |
| 544 // Check the location of the avatar label relative to the avatar button if | 546 // Check the location of the avatar label relative to the avatar button if |
| 545 // both are displayed on the left side. | 547 // both are displayed on the left side. |
| 546 // The label height and width depends on the font size and the text displayed. | 548 // The label height and width depends on the font size and the text displayed. |
| 547 // This may possibly change, so we don't test it here. | 549 // This may possibly change, so we don't test it here. |
| 548 EXPECT_EQ(menu_button_->bounds().x() - 2, avatar_label_->bounds().x()); | 550 EXPECT_EQ(menu_button_->bounds().x() - 2, avatar_label_->bounds().x()); |
| 549 EXPECT_EQ( | 551 EXPECT_EQ( |
| 550 menu_button_->bounds().bottom() - 3 - avatar_label_->bounds().height(), | 552 menu_button_->bounds().bottom() - 3 - avatar_label_->bounds().height(), |
| 551 avatar_label_->bounds().y()); | 553 avatar_label_->bounds().y()); |
| 552 } | 554 } |
| OLD | NEW |