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_strip.h" | 5 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "chrome/browser/ui/views/tabs/fake_base_tab_strip_controller.h" | 8 #include "chrome/browser/ui/views/tabs/fake_base_tab_strip_controller.h" |
9 #include "chrome/browser/ui/views/tabs/tab.h" | 9 #include "chrome/browser/ui/views/tabs/tab.h" |
10 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 10 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 ASSERT_TRUE(active_tab->IsActive()); | 245 ASSERT_TRUE(active_tab->IsActive()); |
246 | 246 |
247 Tab* right_tab = tab_strip_->tab_at(2); | 247 Tab* right_tab = tab_strip_->tab_at(2); |
248 right_tab->SetBoundsRect(gfx::Rect(gfx::Point(300, 0), gfx::Size(200, 20))); | 248 right_tab->SetBoundsRect(gfx::Rect(gfx::Point(300, 0), gfx::Size(200, 20))); |
249 | 249 |
250 Tab* most_right_tab = tab_strip_->tab_at(3); | 250 Tab* most_right_tab = tab_strip_->tab_at(3); |
251 most_right_tab->SetBoundsRect(gfx::Rect(gfx::Point(450, 0), | 251 most_right_tab->SetBoundsRect(gfx::Rect(gfx::Point(450, 0), |
252 gfx::Size(200, 20))); | 252 gfx::Size(200, 20))); |
253 | 253 |
254 // Switch to stacked layout mode and force a layout to ensure tabs stack. | 254 // Switch to stacked layout mode and force a layout to ensure tabs stack. |
255 tab_strip_->SetLayoutType(TAB_STRIP_LAYOUT_STACKED, false); | 255 tab_strip_->SetStackedLayout(true); |
256 tab_strip_->DoLayout(); | 256 tab_strip_->DoLayout(); |
257 | 257 |
258 | 258 |
259 // Tests involving |left_tab|, which has part of its bounds and its tab | 259 // Tests involving |left_tab|, which has part of its bounds and its tab |
260 // close button completely occluded by |active_tab|. | 260 // close button completely occluded by |active_tab|. |
261 | 261 |
262 // Bounds of the tab's hit test mask. | 262 // Bounds of the tab's hit test mask. |
263 gfx::Rect tab_bounds = GetTabHitTestMask(left_tab); | 263 gfx::Rect tab_bounds = GetTabHitTestMask(left_tab); |
264 EXPECT_EQ(gfx::Rect(6, 2, 61, 27).ToString(), tab_bounds.ToString()); | 264 EXPECT_EQ(gfx::Rect(6, 2, 61, 27).ToString(), tab_bounds.ToString()); |
265 | 265 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 ASSERT_EQ(2, tab_strip_->tab_count()); | 371 ASSERT_EQ(2, tab_strip_->tab_count()); |
372 | 372 |
373 Tab* left_tab = tab_strip_->tab_at(0); | 373 Tab* left_tab = tab_strip_->tab_at(0); |
374 left_tab->SetBoundsRect(gfx::Rect(gfx::Point(0, 0), gfx::Size(200, 20))); | 374 left_tab->SetBoundsRect(gfx::Rect(gfx::Point(0, 0), gfx::Size(200, 20))); |
375 | 375 |
376 Tab* active_tab = tab_strip_->tab_at(1); | 376 Tab* active_tab = tab_strip_->tab_at(1); |
377 active_tab->SetBoundsRect(gfx::Rect(gfx::Point(180, 0), gfx::Size(200, 20))); | 377 active_tab->SetBoundsRect(gfx::Rect(gfx::Point(180, 0), gfx::Size(200, 20))); |
378 ASSERT_TRUE(active_tab->IsActive()); | 378 ASSERT_TRUE(active_tab->IsActive()); |
379 | 379 |
380 // Switch to stacked layout mode and force a layout to ensure tabs stack. | 380 // Switch to stacked layout mode and force a layout to ensure tabs stack. |
381 tab_strip_->SetLayoutType(TAB_STRIP_LAYOUT_STACKED, false); | 381 tab_strip_->SetStackedLayout(true); |
382 tab_strip_->DoLayout(); | 382 tab_strip_->DoLayout(); |
383 | 383 |
384 | 384 |
385 // Tests involving |left_tab|, which has part of its bounds and its tab | 385 // Tests involving |left_tab|, which has part of its bounds and its tab |
386 // close button partially occluded by |active_tab|. | 386 // close button partially occluded by |active_tab|. |
387 | 387 |
388 // Bounds of the tab's hit test mask. | 388 // Bounds of the tab's hit test mask. |
389 gfx::Rect tab_bounds = GetTabHitTestMask(left_tab); | 389 gfx::Rect tab_bounds = GetTabHitTestMask(left_tab); |
390 EXPECT_EQ(gfx::Rect(6, 2, 91, 27).ToString(), tab_bounds.ToString()); | 390 EXPECT_EQ(gfx::Rect(6, 2, 91, 27).ToString(), tab_bounds.ToString()); |
391 | 391 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 ASSERT_TRUE(IsPointInTab(most_right_tab, unactive_overlap)); | 541 ASSERT_TRUE(IsPointInTab(most_right_tab, unactive_overlap)); |
542 | 542 |
543 EXPECT_EQ( | 543 EXPECT_EQ( |
544 right_tab, | 544 right_tab, |
545 FindTabView(tab_strip_->GetTooltipHandlerForPoint(unactive_overlap))); | 545 FindTabView(tab_strip_->GetTooltipHandlerForPoint(unactive_overlap))); |
546 | 546 |
547 // Confirm that tab strip doe not return tooltip handler for points that | 547 // Confirm that tab strip doe not return tooltip handler for points that |
548 // don't hit it. | 548 // don't hit it. |
549 EXPECT_FALSE(tab_strip_->GetTooltipHandlerForPoint(gfx::Point(-1, 2))); | 549 EXPECT_FALSE(tab_strip_->GetTooltipHandlerForPoint(gfx::Point(-1, 2))); |
550 } | 550 } |
OLD | NEW |