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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 init_params.bounds = gfx::Rect(0, 0, 200, 200); | 116 init_params.bounds = gfx::Rect(0, 0, 200, 200); |
117 widget_->Init(init_params); | 117 widget_->Init(init_params); |
118 widget_->SetContentsView(&parent_); | 118 widget_->SetContentsView(&parent_); |
119 } | 119 } |
120 | 120 |
121 void TearDown() override { | 121 void TearDown() override { |
122 widget_.reset(); | 122 widget_.reset(); |
123 views::ViewsTestBase::TearDown(); | 123 views::ViewsTestBase::TearDown(); |
124 } | 124 } |
125 | 125 |
126 // Forces a relayout of all tabs in |tab_strip_|. Used in testing to verify | |
127 // that tab close buttons are shown/hidden. | |
128 void ForceLayoutOfAllTabs() { | |
sky
2015/03/11 19:55:16
You shouldn't have to do this in the test. TabStri
tdanderson
2015/03/11 21:10:51
Changed to forcing a paint instead based on offlin
| |
129 for (int i = 0; i < tab_strip_->tab_count(); ++i) | |
130 tab_strip_->tab_at(i)->Layout(); | |
131 } | |
132 | |
126 protected: | 133 protected: |
127 // Returns the rectangular hit test region of |tab| in |tab|'s local | 134 // Returns the rectangular hit test region of |tab| in |tab|'s local |
128 // coordinate space. | 135 // coordinate space. |
129 gfx::Rect GetTabHitTestMask(Tab* tab) { | 136 gfx::Rect GetTabHitTestMask(Tab* tab) { |
130 views::ViewTargeter* targeter = tab->targeter(); | 137 views::ViewTargeter* targeter = tab->targeter(); |
131 DCHECK(targeter); | 138 DCHECK(targeter); |
132 views::MaskedTargeterDelegate* delegate = | 139 views::MaskedTargeterDelegate* delegate = |
133 static_cast<views::MaskedTargeterDelegate*>(tab); | 140 static_cast<views::MaskedTargeterDelegate*>(tab); |
134 | 141 |
135 gfx::Path mask; | 142 gfx::Path mask; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
309 | 316 |
310 // Now tabs have the immersive height. | 317 // Now tabs have the immersive height. |
311 int immersive_height = Tab::GetImmersiveHeight(); | 318 int immersive_height = Tab::GetImmersiveHeight(); |
312 EXPECT_EQ(immersive_height, tab_strip_->GetPreferredSize().height()); | 319 EXPECT_EQ(immersive_height, tab_strip_->GetPreferredSize().height()); |
313 | 320 |
314 // Sanity-check immersive tabs are shorter than normal tabs. | 321 // Sanity-check immersive tabs are shorter than normal tabs. |
315 EXPECT_LT(immersive_height, normal_height); | 322 EXPECT_LT(immersive_height, normal_height); |
316 } | 323 } |
317 | 324 |
318 // Creates a tab strip in stacked layout mode and verifies the correctness | 325 // Creates a tab strip in stacked layout mode and verifies the correctness |
319 // of hit tests against the visible/occluded regions of a tab and | 326 // of hit tests against the visible/occluded regions of a tab and the tab |
320 // visible/occluded tab close buttons. | 327 // close button of the active tab. |
321 TEST_F(TabStripTest, TabHitTestMaskWhenStacked) { | 328 TEST_F(TabStripTest, TabHitTestMaskWhenStacked) { |
322 tab_strip_->SetBounds(0, 0, 300, 20); | 329 tab_strip_->SetBounds(0, 0, 300, 20); |
323 | 330 |
324 controller_->AddTab(0, false); | 331 controller_->AddTab(0, false); |
325 controller_->AddTab(1, true); | 332 controller_->AddTab(1, true); |
326 controller_->AddTab(2, false); | 333 controller_->AddTab(2, false); |
327 controller_->AddTab(3, false); | 334 controller_->AddTab(3, false); |
328 ASSERT_EQ(4, tab_strip_->tab_count()); | 335 ASSERT_EQ(4, tab_strip_->tab_count()); |
329 | 336 |
330 Tab* left_tab = tab_strip_->tab_at(0); | 337 Tab* left_tab = tab_strip_->tab_at(0); |
331 left_tab->SetBoundsRect(gfx::Rect(gfx::Point(0, 0), gfx::Size(200, 20))); | 338 left_tab->SetBoundsRect(gfx::Rect(gfx::Point(0, 0), gfx::Size(200, 20))); |
332 | 339 |
333 Tab* active_tab = tab_strip_->tab_at(1); | 340 Tab* active_tab = tab_strip_->tab_at(1); |
334 active_tab->SetBoundsRect(gfx::Rect(gfx::Point(150, 0), gfx::Size(200, 20))); | 341 active_tab->SetBoundsRect(gfx::Rect(gfx::Point(150, 0), gfx::Size(200, 20))); |
335 ASSERT_TRUE(active_tab->IsActive()); | 342 ASSERT_TRUE(active_tab->IsActive()); |
336 | 343 |
337 Tab* right_tab = tab_strip_->tab_at(2); | 344 Tab* right_tab = tab_strip_->tab_at(2); |
338 right_tab->SetBoundsRect(gfx::Rect(gfx::Point(300, 0), gfx::Size(200, 20))); | 345 right_tab->SetBoundsRect(gfx::Rect(gfx::Point(300, 0), gfx::Size(200, 20))); |
339 | 346 |
340 Tab* most_right_tab = tab_strip_->tab_at(3); | 347 Tab* most_right_tab = tab_strip_->tab_at(3); |
341 most_right_tab->SetBoundsRect(gfx::Rect(gfx::Point(450, 0), | 348 most_right_tab->SetBoundsRect(gfx::Rect(gfx::Point(450, 0), |
342 gfx::Size(200, 20))); | 349 gfx::Size(200, 20))); |
343 | 350 |
344 // Switch to stacked layout mode and force a layout to ensure tabs stack. | 351 // Switch to stacked layout mode and force a layout to ensure tabs stack. |
345 tab_strip_->SetStackedLayout(true); | 352 tab_strip_->SetStackedLayout(true); |
346 tab_strip_->DoLayout(); | 353 tab_strip_->DoLayout(); |
347 | 354 |
348 | 355 |
349 // Tests involving |left_tab|, which has part of its bounds and its tab | 356 // Tests involving |left_tab|, which has part of its bounds occluded by |
350 // close button completely occluded by |active_tab|. | 357 // |active_tab|. |
351 | 358 |
352 // Bounds of the tab's hit test mask. | 359 // Bounds of the tab's hit test mask. |
353 gfx::Rect tab_bounds = GetTabHitTestMask(left_tab); | 360 gfx::Rect tab_bounds = GetTabHitTestMask(left_tab); |
354 EXPECT_EQ(gfx::Rect(6, 2, 61, 27).ToString(), tab_bounds.ToString()); | 361 EXPECT_EQ(gfx::Rect(6, 2, 61, 27).ToString(), tab_bounds.ToString()); |
355 | 362 |
356 // Bounds of the tab close button (without padding) in the tab's | |
357 // coordinate space. | |
358 gfx::Rect contents_bounds = GetTabCloseHitTestMask(left_tab, false); | |
359 // TODO(tdanderson): Uncomment this line once crbug.com/311609 is resolved. | |
360 //EXPECT_EQ(gfx::Rect(84, 8, 18, 18).ToString(), contents_bounds.ToString()); | |
361 | |
362 // Verify that the tab close button is completely occluded. | |
363 EXPECT_FALSE(tab_bounds.Contains(contents_bounds)); | |
364 | |
365 // Hit tests in the non-occuluded region of the tab. | 363 // Hit tests in the non-occuluded region of the tab. |
366 EXPECT_TRUE(left_tab->HitTestRect(gfx::Rect(6, 2, 2, 2))); | 364 EXPECT_TRUE(left_tab->HitTestRect(gfx::Rect(6, 2, 2, 2))); |
367 EXPECT_TRUE(left_tab->HitTestRect(gfx::Rect(6, 2, 1, 1))); | 365 EXPECT_TRUE(left_tab->HitTestRect(gfx::Rect(6, 2, 1, 1))); |
368 EXPECT_TRUE(left_tab->HitTestRect(gfx::Rect(30, 15, 1, 1))); | 366 EXPECT_TRUE(left_tab->HitTestRect(gfx::Rect(30, 15, 1, 1))); |
369 EXPECT_TRUE(left_tab->HitTestRect(gfx::Rect(30, 15, 25, 35))); | 367 EXPECT_TRUE(left_tab->HitTestRect(gfx::Rect(30, 15, 25, 35))); |
370 EXPECT_TRUE(left_tab->HitTestRect(gfx::Rect(-10, -5, 20, 30))); | 368 EXPECT_TRUE(left_tab->HitTestRect(gfx::Rect(-10, -5, 20, 30))); |
371 | 369 |
372 // Hit tests in the occluded region of the tab. | 370 // Hit tests in the occluded region of the tab. |
373 EXPECT_FALSE(left_tab->HitTestRect(gfx::Rect(70, 15, 2, 2))); | 371 EXPECT_FALSE(left_tab->HitTestRect(gfx::Rect(70, 15, 2, 2))); |
374 EXPECT_FALSE(left_tab->HitTestRect(gfx::Rect(70, -15, 30, 40))); | 372 EXPECT_FALSE(left_tab->HitTestRect(gfx::Rect(70, -15, 30, 40))); |
375 EXPECT_FALSE(left_tab->HitTestRect(gfx::Rect(87, 20, 5, 3))); | 373 EXPECT_FALSE(left_tab->HitTestRect(gfx::Rect(87, 20, 5, 3))); |
376 | 374 |
377 // Hit tests completely outside of the tab. | 375 // Hit tests completely outside of the tab. |
378 EXPECT_FALSE(left_tab->HitTestRect(gfx::Rect(-20, -25, 1, 1))); | 376 EXPECT_FALSE(left_tab->HitTestRect(gfx::Rect(-20, -25, 1, 1))); |
379 EXPECT_FALSE(left_tab->HitTestRect(gfx::Rect(-20, -25, 3, 19))); | 377 EXPECT_FALSE(left_tab->HitTestRect(gfx::Rect(-20, -25, 3, 19))); |
380 | 378 |
381 // All hit tests against the tab close button should fail because | |
382 // it is occluded by |active_tab|. | |
383 views::ImageButton* left_close = left_tab->close_button_; | |
384 EXPECT_FALSE(left_close->HitTestRect(gfx::Rect(1, 1, 1, 1))); | |
385 EXPECT_FALSE(left_close->HitTestRect(gfx::Rect(1, 1, 5, 10))); | |
386 EXPECT_FALSE(left_close->HitTestRect(gfx::Rect(10, 10, 1, 1))); | |
387 EXPECT_FALSE(left_close->HitTestRect(gfx::Rect(10, 10, 3, 4))); | |
388 | |
389 | 379 |
390 // Tests involving |active_tab|, which is completely visible. | 380 // Tests involving |active_tab|, which is completely visible. |
391 | 381 |
392 tab_bounds = GetTabHitTestMask(active_tab); | 382 tab_bounds = GetTabHitTestMask(active_tab); |
393 EXPECT_EQ(gfx::Rect(6, 2, 108, 27).ToString(), tab_bounds.ToString()); | 383 EXPECT_EQ(gfx::Rect(6, 2, 108, 27).ToString(), tab_bounds.ToString()); |
394 contents_bounds = GetTabCloseHitTestMask(active_tab, false); | 384 gfx::Rect contents_bounds = GetTabCloseHitTestMask(active_tab, false); |
395 // TODO(tdanderson): Uncomment this line once crbug.com/311609 is resolved. | 385 // TODO(tdanderson): Uncomment this line once crbug.com/311609 is resolved. |
396 //EXPECT_EQ(gfx::Rect(84, 8, 18, 18).ToString(), contents_bounds.ToString()); | 386 // EXPECT_EQ(gfx::Rect(84, 8, 18, 18).ToString(), contents_bounds.ToString()); |
397 | 387 |
398 // Verify that the tab close button is not occluded. | 388 // Verify that the tab close button is not occluded. |
399 EXPECT_TRUE(tab_bounds.Contains(contents_bounds)); | 389 EXPECT_TRUE(tab_bounds.Contains(contents_bounds)); |
400 | 390 |
401 // Bounds of the tab close button (without padding) in the tab's | 391 // Bounds of the tab close button (without padding) in the tab's |
402 // coordinate space. | 392 // coordinate space. |
403 gfx::Rect local_bounds = GetTabCloseHitTestMask(active_tab, true); | 393 gfx::Rect local_bounds = GetTabCloseHitTestMask(active_tab, true); |
404 EXPECT_EQ(gfx::Rect(81, 0, 39, 29).ToString(), local_bounds.ToString()); | 394 EXPECT_EQ(gfx::Rect(81, 0, 39, 29).ToString(), local_bounds.ToString()); |
405 | 395 |
406 // Hit tests within the tab. | 396 // Hit tests within the tab. |
407 EXPECT_TRUE(active_tab->HitTestRect(gfx::Rect(30, 15, 1, 1))); | 397 EXPECT_TRUE(active_tab->HitTestRect(gfx::Rect(30, 15, 1, 1))); |
408 EXPECT_TRUE(active_tab->HitTestRect(gfx::Rect(30, 15, 2, 2))); | 398 EXPECT_TRUE(active_tab->HitTestRect(gfx::Rect(30, 15, 2, 2))); |
409 | 399 |
410 // Hit tests against the tab close button. Note that hit tests from either | 400 // Hit tests against the tab close button. Note that hit tests from either |
411 // mouse or touch should both fail if they are strictly contained within | 401 // mouse or touch should both fail if they are strictly contained within |
412 // the button's padding. | 402 // the button's padding. |
413 views::ImageButton* active_close = active_tab->close_button_; | 403 views::ImageButton* active_close = active_tab->close_button_; |
414 EXPECT_FALSE(active_close->HitTestRect(gfx::Rect(1, 1, 1, 1))); | 404 EXPECT_FALSE(active_close->HitTestRect(gfx::Rect(1, 1, 1, 1))); |
415 EXPECT_FALSE(active_close->HitTestRect(gfx::Rect(1, 1, 2, 2))); | 405 EXPECT_FALSE(active_close->HitTestRect(gfx::Rect(1, 1, 2, 2))); |
416 EXPECT_TRUE(active_close->HitTestRect(gfx::Rect(10, 10, 1, 1))); | 406 EXPECT_TRUE(active_close->HitTestRect(gfx::Rect(10, 10, 1, 1))); |
417 EXPECT_TRUE(active_close->HitTestRect(gfx::Rect(10, 10, 25, 35))); | 407 EXPECT_TRUE(active_close->HitTestRect(gfx::Rect(10, 10, 25, 35))); |
418 | 408 |
419 | 409 |
420 // Tests involving |most_right_tab|, which has part of its bounds occluded | 410 // Tests involving |most_right_tab|, which has part of its bounds occluded |
421 // by |right_tab| but has its tab close button completely visible. | 411 // by |right_tab|. |
422 | 412 |
423 tab_bounds = GetTabHitTestMask(most_right_tab); | 413 tab_bounds = GetTabHitTestMask(most_right_tab); |
424 EXPECT_EQ(gfx::Rect(84, 2, 30, 27).ToString(), tab_bounds.ToString()); | 414 EXPECT_EQ(gfx::Rect(84, 2, 30, 27).ToString(), tab_bounds.ToString()); |
425 contents_bounds = GetTabCloseHitTestMask(active_tab, false); | |
426 // TODO(tdanderson): Uncomment this line once crbug.com/311609 is resolved. | |
427 //EXPECT_EQ(gfx::Rect(84, 8, 18, 18).ToString(), contents_bounds.ToString()); | |
428 local_bounds = GetTabCloseHitTestMask(active_tab, true); | |
429 EXPECT_EQ(gfx::Rect(81, 0, 39, 29).ToString(), local_bounds.ToString()); | |
430 | |
431 // Verify that the tab close button is not occluded. | |
432 EXPECT_TRUE(tab_bounds.Contains(contents_bounds)); | |
433 | 415 |
434 // Hit tests in the occluded region of the tab. | 416 // Hit tests in the occluded region of the tab. |
435 EXPECT_FALSE(most_right_tab->HitTestRect(gfx::Rect(20, 15, 1, 1))); | 417 EXPECT_FALSE(most_right_tab->HitTestRect(gfx::Rect(20, 15, 1, 1))); |
436 EXPECT_FALSE(most_right_tab->HitTestRect(gfx::Rect(20, 15, 5, 6))); | 418 EXPECT_FALSE(most_right_tab->HitTestRect(gfx::Rect(20, 15, 5, 6))); |
437 | 419 |
438 // Hit tests in the non-occluded region of the tab. | 420 // Hit tests in the non-occluded region of the tab. |
439 EXPECT_TRUE(most_right_tab->HitTestRect(gfx::Rect(85, 15, 1, 1))); | 421 EXPECT_TRUE(most_right_tab->HitTestRect(gfx::Rect(85, 15, 1, 1))); |
440 EXPECT_TRUE(most_right_tab->HitTestRect(gfx::Rect(85, 15, 2, 2))); | 422 EXPECT_TRUE(most_right_tab->HitTestRect(gfx::Rect(85, 15, 2, 2))); |
441 | |
442 // Hit tests against the tab close button. Note that hit tests from either | |
443 // mouse or touch should both fail if they are strictly contained within | |
444 // the button's padding. | |
445 views::ImageButton* most_right_close = most_right_tab->close_button_; | |
446 EXPECT_FALSE(most_right_close->HitTestRect(gfx::Rect(1, 1, 1, 1))); | |
447 EXPECT_FALSE(most_right_close->HitTestRect(gfx::Rect(1, 1, 2, 2))); | |
448 EXPECT_TRUE(most_right_close->HitTestRect(gfx::Rect(10, 10, 1, 1))); | |
449 EXPECT_TRUE(most_right_close->HitTestRect(gfx::Rect(10, 10, 25, 35))); | |
450 EXPECT_TRUE(most_right_close->HitTestRect(gfx::Rect(-10, 10, 25, 35))); | |
451 } | 423 } |
452 | 424 |
453 // Creates a tab strip in stacked layout mode and verifies the correctness | 425 // Tests that the tab close buttons of non-active tabs are hidden when |
454 // of hit tests against the visible/occluded region of a partially-occluded | 426 // the tabstrip is in stacked tab mode. |
455 // tab close button. | 427 TEST_F(TabStripTest, TabCloseButtonVisibilityWhenStacked) { |
456 TEST_F(TabStripTest, ClippedTabCloseButton) { | 428 tab_strip_->SetBounds(0, 0, 300, 20); |
457 tab_strip_->SetBounds(0, 0, 220, 20); | |
458 | |
459 controller_->AddTab(0, false); | 429 controller_->AddTab(0, false); |
460 controller_->AddTab(1, true); | 430 controller_->AddTab(1, true); |
461 ASSERT_EQ(2, tab_strip_->tab_count()); | 431 controller_->AddTab(2, false); |
432 ASSERT_EQ(3, tab_strip_->tab_count()); | |
462 | 433 |
463 Tab* left_tab = tab_strip_->tab_at(0); | 434 Tab* tab0 = tab_strip_->tab_at(0); |
464 left_tab->SetBoundsRect(gfx::Rect(gfx::Point(0, 0), gfx::Size(200, 20))); | 435 Tab* tab1 = tab_strip_->tab_at(1); |
436 ASSERT_TRUE(tab1->IsActive()); | |
437 Tab* tab2 = tab_strip_->tab_at(2); | |
465 | 438 |
466 Tab* active_tab = tab_strip_->tab_at(1); | 439 // Ensure that all tab close buttons are initially visible. |
467 active_tab->SetBoundsRect(gfx::Rect(gfx::Point(180, 0), gfx::Size(200, 20))); | 440 ForceLayoutOfAllTabs(); |
468 ASSERT_TRUE(active_tab->IsActive()); | 441 EXPECT_TRUE(tab0->showing_close_button_); |
442 EXPECT_TRUE(tab1->showing_close_button_); | |
443 EXPECT_TRUE(tab2->showing_close_button_); | |
469 | 444 |
470 // Switch to stacked layout mode and force a layout to ensure tabs stack. | 445 // Enter stacked layout mode and verify this sets |touch_layout_|. |
446 ASSERT_FALSE(tab_strip_->touch_layout_.get()); | |
471 tab_strip_->SetStackedLayout(true); | 447 tab_strip_->SetStackedLayout(true); |
472 tab_strip_->DoLayout(); | 448 ForceLayoutOfAllTabs(); |
449 ASSERT_TRUE(tab_strip_->touch_layout_.get()); | |
473 | 450 |
451 // Only the close button of the active tab should be visible in stacked | |
452 // layout mode. | |
453 EXPECT_FALSE(tab0->showing_close_button_); | |
454 EXPECT_TRUE(tab1->showing_close_button_); | |
455 EXPECT_FALSE(tab2->showing_close_button_); | |
474 | 456 |
475 // Tests involving |left_tab|, which has part of its bounds and its tab | 457 // An inactive tab added to the tabstrip should not show |
476 // close button partially occluded by |active_tab|. | 458 // its tab close button. |
459 controller_->AddTab(3, false); | |
460 Tab* tab3 = tab_strip_->tab_at(3); | |
461 EXPECT_FALSE(tab0->showing_close_button_); | |
462 EXPECT_TRUE(tab1->showing_close_button_); | |
463 EXPECT_FALSE(tab2->showing_close_button_); | |
464 EXPECT_FALSE(tab3->showing_close_button_); | |
477 | 465 |
478 // Bounds of the tab's hit test mask. | 466 // After switching tabs, the previously-active tab should have its |
479 gfx::Rect tab_bounds = GetTabHitTestMask(left_tab); | 467 // tab close button hidden and the newly-active tab should show |
480 EXPECT_EQ(gfx::Rect(6, 2, 91, 27).ToString(), tab_bounds.ToString()); | 468 // its tab close button. |
469 tab_strip_->SelectTab(tab2); | |
470 ForceLayoutOfAllTabs(); | |
471 ASSERT_FALSE(tab1->IsActive()); | |
472 ASSERT_TRUE(tab2->IsActive()); | |
473 EXPECT_FALSE(tab0->showing_close_button_); | |
474 EXPECT_FALSE(tab1->showing_close_button_); | |
475 EXPECT_TRUE(tab2->showing_close_button_); | |
476 EXPECT_FALSE(tab3->showing_close_button_); | |
481 | 477 |
482 // Bounds of the tab close button (without padding) in the tab's | 478 // After closing the active tab, the tab which becomes active should |
483 // coordinate space. | 479 // show its tab close button. |
484 gfx::Rect contents_bounds = GetTabCloseHitTestMask(left_tab, false); | 480 tab_strip_->CloseTab(tab1, CLOSE_TAB_FROM_TOUCH); |
485 // TODO(tdanderson): Uncomment this line once crbug.com/311609 is resolved. | 481 tab1 = nullptr; |
486 //EXPECT_EQ(gfx::Rect(84, 8, 18, 18).ToString(), contents_bounds.ToString()); | 482 ASSERT_TRUE(tab2->IsActive()); |
483 ForceLayoutOfAllTabs(); | |
484 EXPECT_FALSE(tab0->showing_close_button_); | |
485 EXPECT_TRUE(tab2->showing_close_button_); | |
486 EXPECT_FALSE(tab3->showing_close_button_); | |
487 | 487 |
488 // Verify that the tab close button is only partially occluded. | 488 // All tab close buttons should be shown when disengaging stacked tab mode. |
489 EXPECT_FALSE(tab_bounds.Contains(contents_bounds)); | 489 tab_strip_->SetStackedLayout(false); |
490 EXPECT_TRUE(tab_bounds.Intersects(contents_bounds)); | 490 ForceLayoutOfAllTabs(); |
491 | 491 ASSERT_FALSE(tab_strip_->touch_layout_.get()); |
492 views::ImageButton* left_close = left_tab->close_button_; | 492 EXPECT_TRUE(tab0->showing_close_button_); |
493 | 493 EXPECT_TRUE(tab2->showing_close_button_); |
494 // Hit tests from mouse should return true if and only if the location | 494 EXPECT_TRUE(tab3->showing_close_button_); |
495 // is within a visible region. | |
496 EXPECT_FALSE(left_close->HitTestRect(gfx::Rect(2, 15, 1, 1))); | |
497 EXPECT_TRUE(left_close->HitTestRect(gfx::Rect(3, 15, 1, 1))); | |
498 EXPECT_TRUE(left_close->HitTestRect(gfx::Rect(10, 10, 1, 1))); | |
499 EXPECT_TRUE(left_close->HitTestRect(gfx::Rect(15, 12, 1, 1))); | |
500 EXPECT_FALSE(left_close->HitTestRect(gfx::Rect(16, 10, 1, 1))); | |
501 | |
502 // All hit tests from touch should return false because the button is | |
503 // not fully visible. | |
504 EXPECT_FALSE(left_close->HitTestRect(gfx::Rect(2, 15, 2, 2))); | |
505 EXPECT_FALSE(left_close->HitTestRect(gfx::Rect(3, 15, 25, 25))); | |
506 EXPECT_FALSE(left_close->HitTestRect(gfx::Rect(10, 10, 4, 5))); | |
507 EXPECT_FALSE(left_close->HitTestRect(gfx::Rect(15, 12, 2, 2))); | |
508 EXPECT_FALSE(left_close->HitTestRect(gfx::Rect(16, 10, 20, 20))); | |
509 } | 495 } |
510 | 496 |
511 TEST_F(TabStripTest, GetEventHandlerForOverlappingArea) { | 497 TEST_F(TabStripTest, GetEventHandlerForOverlappingArea) { |
512 tab_strip_->SetBounds(0, 0, 1000, 20); | 498 tab_strip_->SetBounds(0, 0, 1000, 20); |
513 | 499 |
514 controller_->AddTab(0, false); | 500 controller_->AddTab(0, false); |
515 controller_->AddTab(1, true); | 501 controller_->AddTab(1, true); |
516 controller_->AddTab(2, false); | 502 controller_->AddTab(2, false); |
517 controller_->AddTab(3, false); | 503 controller_->AddTab(3, false); |
518 ASSERT_EQ(4, tab_strip_->tab_count()); | 504 ASSERT_EQ(4, tab_strip_->tab_count()); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
631 ASSERT_TRUE(IsPointInTab(most_right_tab, unactive_overlap)); | 617 ASSERT_TRUE(IsPointInTab(most_right_tab, unactive_overlap)); |
632 | 618 |
633 EXPECT_EQ( | 619 EXPECT_EQ( |
634 right_tab, | 620 right_tab, |
635 FindTabView(tab_strip_->GetTooltipHandlerForPoint(unactive_overlap))); | 621 FindTabView(tab_strip_->GetTooltipHandlerForPoint(unactive_overlap))); |
636 | 622 |
637 // Confirm that tab strip doe not return tooltip handler for points that | 623 // Confirm that tab strip doe not return tooltip handler for points that |
638 // don't hit it. | 624 // don't hit it. |
639 EXPECT_FALSE(tab_strip_->GetTooltipHandlerForPoint(gfx::Point(-1, 2))); | 625 EXPECT_FALSE(tab_strip_->GetTooltipHandlerForPoint(gfx::Point(-1, 2))); |
640 } | 626 } |
OLD | NEW |