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 #include "chrome/browser/ui/views/tabs/tab.h" | 5 #include "chrome/browser/ui/views/tabs/tab.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 gfx::Insets close_button_insets_2 = GetCloseButton(tab)->GetInsets(); | 401 gfx::Insets close_button_insets_2 = GetCloseButton(tab)->GetInsets(); |
402 EXPECT_EQ(close_button_insets.top(), close_button_insets_2.top()); | 402 EXPECT_EQ(close_button_insets.top(), close_button_insets_2.top()); |
403 EXPECT_EQ(close_button_insets.left(), close_button_insets_2.left()); | 403 EXPECT_EQ(close_button_insets.left(), close_button_insets_2.left()); |
404 EXPECT_EQ(close_button_insets.bottom(), close_button_insets_2.bottom()); | 404 EXPECT_EQ(close_button_insets.bottom(), close_button_insets_2.bottom()); |
405 EXPECT_EQ(close_button_insets.right(), close_button_insets_2.right()); | 405 EXPECT_EQ(close_button_insets.right(), close_button_insets_2.right()); |
406 | 406 |
407 // Also make sure the close button is sized as large as the tab. | 407 // Also make sure the close button is sized as large as the tab. |
408 EXPECT_EQ(50, GetCloseButton(tab)->bounds().height()); | 408 EXPECT_EQ(50, GetCloseButton(tab)->bounds().height()); |
409 } | 409 } |
410 | 410 |
| 411 // Regression test for http://crbug.com/609701. Ensure TabCloseButton does not |
| 412 // get focus on right click. |
| 413 TEST_F(TabTest, CloseButtonFocus) { |
| 414 Widget widget; |
| 415 InitWidget(&widget); |
| 416 FakeTabController tab_controller; |
| 417 Tab tab(&tab_controller, nullptr); |
| 418 widget.GetContentsView()->AddChildView(&tab); |
| 419 |
| 420 views::ImageButton* tab_close_button = GetCloseButton(tab); |
| 421 |
| 422 // Verify tab_close_button does not get focus on right click. |
| 423 ui::MouseEvent right_click_event(ui::ET_KEY_PRESSED, gfx::Point(), |
| 424 gfx::Point(), base::TimeDelta(), |
| 425 ui::EF_RIGHT_MOUSE_BUTTON, 0); |
| 426 tab_close_button->OnMousePressed(right_click_event); |
| 427 EXPECT_NE(tab_close_button, |
| 428 tab_close_button->GetFocusManager()->GetFocusedView()); |
| 429 } |
| 430 |
411 // Tests expected changes to the ThrobberView state when the WebContents loading | 431 // Tests expected changes to the ThrobberView state when the WebContents loading |
412 // state changes or the animation timer (usually in BrowserView) triggers. | 432 // state changes or the animation timer (usually in BrowserView) triggers. |
413 TEST_F(TabTest, LayeredThrobber) { | 433 TEST_F(TabTest, LayeredThrobber) { |
414 Widget widget; | 434 Widget widget; |
415 InitWidget(&widget); | 435 InitWidget(&widget); |
416 | 436 |
417 FakeTabController tab_controller; | 437 FakeTabController tab_controller; |
418 Tab tab(&tab_controller, nullptr); | 438 Tab tab(&tab_controller, nullptr); |
419 widget.GetContentsView()->AddChildView(&tab); | 439 widget.GetContentsView()->AddChildView(&tab); |
420 tab.SetBoundsRect(gfx::Rect(Tab::GetStandardSize())); | 440 tab.SetBoundsRect(gfx::Rect(Tab::GetStandardSize())); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 } | 485 } |
466 | 486 |
467 TEST_F(TabTest, TitleHiddenWhenSmall) { | 487 TEST_F(TabTest, TitleHiddenWhenSmall) { |
468 FakeTabController tab_controller; | 488 FakeTabController tab_controller; |
469 Tab tab(&tab_controller, nullptr); | 489 Tab tab(&tab_controller, nullptr); |
470 tab.SetBounds(0, 0, 100, 50); | 490 tab.SetBounds(0, 0, 100, 50); |
471 EXPECT_GT(GetTitleWidth(tab), 0); | 491 EXPECT_GT(GetTitleWidth(tab), 0); |
472 tab.SetBounds(0, 0, 0, 50); | 492 tab.SetBounds(0, 0, 0, 50); |
473 EXPECT_EQ(0, GetTitleWidth(tab)); | 493 EXPECT_EQ(0, GetTitleWidth(tab)); |
474 } | 494 } |
OLD | NEW |