Index: chrome/browser/ui/views/tabs/tab_unittest.cc |
diff --git a/chrome/browser/ui/views/tabs/tab_unittest.cc b/chrome/browser/ui/views/tabs/tab_unittest.cc |
index e475417e910223a6e0032f0401b139c530f839a1..5db1e92bc5a75cde66153eed98b565d65adeb4d4 100644 |
--- a/chrome/browser/ui/views/tabs/tab_unittest.cc |
+++ b/chrome/browser/ui/views/tabs/tab_unittest.cc |
@@ -33,6 +33,7 @@ class FakeTabController : public TabController { |
virtual void ToggleSelected(Tab* tab) OVERRIDE {} |
virtual void AddSelectionFromAnchorTo(Tab* tab) OVERRIDE {} |
virtual void CloseTab(Tab* tab, CloseTabSource source) OVERRIDE {} |
+ virtual void ToggleTabAudioMute(Tab* tab) OVERRIDE {} |
virtual void ShowContextMenuForTab(Tab* tab, |
const gfx::Point& p, |
ui::MenuSourceType source_type) OVERRIDE {} |
@@ -76,11 +77,6 @@ class TabTest : public views::ViewsTestBase { |
TabTest() {} |
virtual ~TabTest() {} |
- static void DisableMediaIndicatorAnimation(Tab* tab) { |
- tab->media_indicator_animation_.reset(); |
- tab->animating_media_state_ = tab->data_.media_state; |
- } |
- |
static void CheckForExpectedLayoutAndVisibilityOfElements(const Tab& tab) { |
// Check whether elements are visible when they are supposed to be, given |
// Tab size and TabRendererData state. |
@@ -159,20 +155,21 @@ class TabTest : public views::ViewsTestBase { |
EXPECT_LE(tab.favicon_bounds_.bottom(), contents_bounds.bottom()); |
} |
if (tab.ShouldShowIcon() && tab.ShouldShowMediaIndicator()) |
- EXPECT_LE(tab.favicon_bounds_.right(), tab.media_indicator_bounds_.x()); |
+ EXPECT_LE(tab.favicon_bounds_.right(), GetMediaIndicatorBounds(tab).x()); |
if (tab.ShouldShowMediaIndicator()) { |
if (tab.title_->width() > 0) { |
EXPECT_LE(tab.title_->bounds().right(), |
- tab.media_indicator_bounds_.x()); |
+ GetMediaIndicatorBounds(tab).x()); |
} |
- EXPECT_LE(tab.media_indicator_bounds_.right(), contents_bounds.right()); |
- EXPECT_LE(contents_bounds.y(), tab.media_indicator_bounds_.y()); |
- EXPECT_LE(tab.media_indicator_bounds_.bottom(), contents_bounds.bottom()); |
+ EXPECT_LE(GetMediaIndicatorBounds(tab).right(), contents_bounds.right()); |
+ EXPECT_LE(contents_bounds.y(), GetMediaIndicatorBounds(tab).y()); |
+ EXPECT_LE(GetMediaIndicatorBounds(tab).bottom(), |
+ contents_bounds.bottom()); |
} |
if (tab.ShouldShowMediaIndicator() && tab.ShouldShowCloseBox()) { |
// Note: The media indicator can overlap the left-insets of the close box, |
// but should otherwise be to the left of the close button. |
- EXPECT_LE(tab.media_indicator_bounds_.right(), |
+ EXPECT_LE(GetMediaIndicatorBounds(tab).right(), |
tab.close_button_->bounds().x() + |
tab.close_button_->GetInsets().left()); |
} |
@@ -189,6 +186,13 @@ class TabTest : public views::ViewsTestBase { |
EXPECT_LE(tab.close_button_->bounds().bottom(), contents_bounds.bottom()); |
} |
} |
+ |
+ private: |
+ static const gfx::Rect& GetMediaIndicatorBounds(const Tab& tab) { |
+ CHECK(tab.media_indicator_button_); |
sky
2014/09/23 22:58:18
You should ADD_FAILURE here and early return.
miu
2014/09/24 22:34:16
Done.
|
+ return reinterpret_cast<const views::View*>(tab.media_indicator_button_)-> |
+ bounds(); |
+ } |
}; |
TEST_F(TabTest, HitTestTopPixel) { |
@@ -224,7 +228,7 @@ TEST_F(TabTest, HitTestTopPixel) { |
TEST_F(TabTest, LayoutAndVisibilityOfElements) { |
static const TabMediaState kMediaStatesToTest[] = { |
TAB_MEDIA_STATE_NONE, TAB_MEDIA_STATE_CAPTURING, |
- TAB_MEDIA_STATE_AUDIO_PLAYING |
+ TAB_MEDIA_STATE_AUDIO_PLAYING, TAB_MEDIA_STATE_AUDIO_MUTING |
}; |
FakeTabController controller; |
@@ -253,12 +257,6 @@ TEST_F(TabTest, LayoutAndVisibilityOfElements) { |
data.media_state = media_state; |
tab.SetData(data); |
- // Disable the media indicator animation so that the layout/visibility |
- // logic can be tested effectively. If the animation was left enabled, |
- // the ShouldShowMediaIndicator() method would return true during |
- // fade-out transitions. |
- DisableMediaIndicatorAnimation(&tab); |
- |
// Test layout for every width from standard to minimum. |
gfx::Rect bounds(gfx::Point(0, 0), Tab::GetStandardSize()); |
int min_width; |