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 |
| 7 #include "base/strings/utf_string_conversions.h" |
6 #include "chrome/browser/ui/views/tabs/tab_controller.h" | 8 #include "chrome/browser/ui/views/tabs/tab_controller.h" |
7 | |
8 #include "base/strings/utf_string_conversions.h" | |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "ui/base/models/list_selection_model.h" | 10 #include "ui/base/models/list_selection_model.h" |
11 #include "ui/views/controls/button/image_button.h" | 11 #include "ui/views/controls/button/image_button.h" |
| 12 #include "ui/views/controls/label.h" |
12 #include "ui/views/test/views_test_base.h" | 13 #include "ui/views/test/views_test_base.h" |
13 #include "ui/views/widget/widget.h" | 14 #include "ui/views/widget/widget.h" |
14 | 15 |
15 using views::Widget; | 16 using views::Widget; |
16 | 17 |
17 class FakeTabController : public TabController { | 18 class FakeTabController : public TabController { |
18 public: | 19 public: |
19 FakeTabController() : immersive_style_(false), active_tab_(false) { | 20 FakeTabController() : immersive_style_(false), active_tab_(false) { |
20 } | 21 } |
21 virtual ~FakeTabController() {} | 22 virtual ~FakeTabController() {} |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 EXPECT_FALSE(tab.ShouldShowMediaIndicator()); | 144 EXPECT_FALSE(tab.ShouldShowMediaIndicator()); |
144 break; | 145 break; |
145 } | 146 } |
146 } | 147 } |
147 | 148 |
148 // Check positioning of elements with respect to each other, and that they | 149 // Check positioning of elements with respect to each other, and that they |
149 // are fully within the contents bounds. | 150 // are fully within the contents bounds. |
150 const gfx::Rect contents_bounds = tab.GetContentsBounds(); | 151 const gfx::Rect contents_bounds = tab.GetContentsBounds(); |
151 if (tab.ShouldShowIcon()) { | 152 if (tab.ShouldShowIcon()) { |
152 EXPECT_LE(contents_bounds.x(), tab.favicon_bounds_.x()); | 153 EXPECT_LE(contents_bounds.x(), tab.favicon_bounds_.x()); |
153 if (tab.title_bounds_.width() > 0) | 154 if (tab.title_->width() > 0) |
154 EXPECT_LE(tab.favicon_bounds_.right(), tab.title_bounds_.x()); | 155 EXPECT_LE(tab.favicon_bounds_.right(), tab.title_->x()); |
155 EXPECT_LE(contents_bounds.y(), tab.favicon_bounds_.y()); | 156 EXPECT_LE(contents_bounds.y(), tab.favicon_bounds_.y()); |
156 EXPECT_LE(tab.favicon_bounds_.bottom(), contents_bounds.bottom()); | 157 EXPECT_LE(tab.favicon_bounds_.bottom(), contents_bounds.bottom()); |
157 } | 158 } |
158 if (tab.ShouldShowIcon() && tab.ShouldShowMediaIndicator()) | 159 if (tab.ShouldShowIcon() && tab.ShouldShowMediaIndicator()) |
159 EXPECT_LE(tab.favicon_bounds_.right(), tab.media_indicator_bounds_.x()); | 160 EXPECT_LE(tab.favicon_bounds_.right(), tab.media_indicator_bounds_.x()); |
160 if (tab.ShouldShowMediaIndicator()) { | 161 if (tab.ShouldShowMediaIndicator()) { |
161 if (tab.title_bounds_.width() > 0) | 162 if (tab.title_->width() > 0) { |
162 EXPECT_LE(tab.title_bounds_.right(), tab.media_indicator_bounds_.x()); | 163 EXPECT_LE(tab.title_->bounds().right(), |
| 164 tab.media_indicator_bounds_.x()); |
| 165 } |
163 EXPECT_LE(tab.media_indicator_bounds_.right(), contents_bounds.right()); | 166 EXPECT_LE(tab.media_indicator_bounds_.right(), contents_bounds.right()); |
164 EXPECT_LE(contents_bounds.y(), tab.media_indicator_bounds_.y()); | 167 EXPECT_LE(contents_bounds.y(), tab.media_indicator_bounds_.y()); |
165 EXPECT_LE(tab.media_indicator_bounds_.bottom(), contents_bounds.bottom()); | 168 EXPECT_LE(tab.media_indicator_bounds_.bottom(), contents_bounds.bottom()); |
166 } | 169 } |
167 if (tab.ShouldShowMediaIndicator() && tab.ShouldShowCloseBox()) { | 170 if (tab.ShouldShowMediaIndicator() && tab.ShouldShowCloseBox()) { |
168 // Note: The media indicator can overlap the left-insets of the close box, | 171 // Note: The media indicator can overlap the left-insets of the close box, |
169 // but should otherwise be to the left of the close button. | 172 // but should otherwise be to the left of the close button. |
170 EXPECT_LE(tab.media_indicator_bounds_.right(), | 173 EXPECT_LE(tab.media_indicator_bounds_.right(), |
171 tab.close_button_->bounds().x() + | 174 tab.close_button_->bounds().x() + |
172 tab.close_button_->GetInsets().left()); | 175 tab.close_button_->GetInsets().left()); |
173 } | 176 } |
174 if (tab.ShouldShowCloseBox()) { | 177 if (tab.ShouldShowCloseBox()) { |
175 // Note: The title bounds can overlap the left-insets of the close box, | 178 // Note: The title bounds can overlap the left-insets of the close box, |
176 // but should otherwise be to the left of the close button. | 179 // but should otherwise be to the left of the close button. |
177 if (tab.title_bounds_.width() > 0) { | 180 if (tab.title_->width() > 0) { |
178 EXPECT_LE(tab.title_bounds_.right(), | 181 EXPECT_LE(tab.title_->bounds().right(), |
179 tab.close_button_->bounds().x() + | 182 tab.close_button_->bounds().x() + |
180 tab.close_button_->GetInsets().left()); | 183 tab.close_button_->GetInsets().left()); |
181 } | 184 } |
182 EXPECT_LE(tab.close_button_->bounds().right(), contents_bounds.right()); | 185 EXPECT_LE(tab.close_button_->bounds().right(), contents_bounds.right()); |
183 EXPECT_LE(contents_bounds.y(), tab.close_button_->bounds().y()); | 186 EXPECT_LE(contents_bounds.y(), tab.close_button_->bounds().y()); |
184 EXPECT_LE(tab.close_button_->bounds().bottom(), contents_bounds.bottom()); | 187 EXPECT_LE(tab.close_button_->bounds().bottom(), contents_bounds.bottom()); |
185 } | 188 } |
186 } | 189 } |
187 }; | 190 }; |
188 | 191 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 tab.Layout(); | 290 tab.Layout(); |
288 gfx::Insets close_button_insets_2 = tab.close_button_->GetInsets(); | 291 gfx::Insets close_button_insets_2 = tab.close_button_->GetInsets(); |
289 EXPECT_EQ(close_button_insets.top(), close_button_insets_2.top()); | 292 EXPECT_EQ(close_button_insets.top(), close_button_insets_2.top()); |
290 EXPECT_EQ(close_button_insets.left(), close_button_insets_2.left()); | 293 EXPECT_EQ(close_button_insets.left(), close_button_insets_2.left()); |
291 EXPECT_EQ(close_button_insets.bottom(), close_button_insets_2.bottom()); | 294 EXPECT_EQ(close_button_insets.bottom(), close_button_insets_2.bottom()); |
292 EXPECT_EQ(close_button_insets.right(), close_button_insets_2.right()); | 295 EXPECT_EQ(close_button_insets.right(), close_button_insets_2.right()); |
293 | 296 |
294 // Also make sure the close button is sized as large as the tab. | 297 // Also make sure the close button is sized as large as the tab. |
295 EXPECT_EQ(50, tab.close_button_->bounds().height()); | 298 EXPECT_EQ(50, tab.close_button_->bounds().height()); |
296 } | 299 } |
OLD | NEW |