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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } | 52 } |
53 | 53 |
54 int last_tab_added() const { return last_tab_added_; } | 54 int last_tab_added() const { return last_tab_added_; } |
55 int last_tab_removed() const { return last_tab_removed_; } | 55 int last_tab_removed() const { return last_tab_removed_; } |
56 int last_tab_moved_from() const { return last_tab_moved_from_; } | 56 int last_tab_moved_from() const { return last_tab_moved_from_; } |
57 int last_tab_moved_to() const { return last_tab_moved_to_; } | 57 int last_tab_moved_to() const { return last_tab_moved_to_; } |
58 bool tabstrip_deleted() const { return tabstrip_deleted_; } | 58 bool tabstrip_deleted() const { return tabstrip_deleted_; } |
59 | 59 |
60 private: | 60 private: |
61 // TabStripObserver overrides. | 61 // TabStripObserver overrides. |
62 virtual void TabStripAddedTabAt(TabStrip* tab_strip, int index) OVERRIDE { | 62 virtual void TabStripAddedTabAt(TabStrip* tab_strip, int index) override { |
63 last_tab_added_ = index; | 63 last_tab_added_ = index; |
64 } | 64 } |
65 | 65 |
66 virtual void TabStripMovedTab(TabStrip* tab_strip, | 66 virtual void TabStripMovedTab(TabStrip* tab_strip, |
67 int from_index, | 67 int from_index, |
68 int to_index) OVERRIDE { | 68 int to_index) override { |
69 last_tab_moved_from_ = from_index; | 69 last_tab_moved_from_ = from_index; |
70 last_tab_moved_to_ = to_index; | 70 last_tab_moved_to_ = to_index; |
71 } | 71 } |
72 | 72 |
73 virtual void TabStripRemovedTabAt(TabStrip* tab_strip, int index) OVERRIDE { | 73 virtual void TabStripRemovedTabAt(TabStrip* tab_strip, int index) override { |
74 last_tab_removed_ = index; | 74 last_tab_removed_ = index; |
75 } | 75 } |
76 | 76 |
77 virtual void TabStripDeleted(TabStrip* tab_strip) OVERRIDE { | 77 virtual void TabStripDeleted(TabStrip* tab_strip) override { |
78 tabstrip_deleted_ = true; | 78 tabstrip_deleted_ = true; |
79 tab_strip_ = NULL; | 79 tab_strip_ = NULL; |
80 } | 80 } |
81 | 81 |
82 TabStrip* tab_strip_; | 82 TabStrip* tab_strip_; |
83 int last_tab_added_; | 83 int last_tab_added_; |
84 int last_tab_removed_; | 84 int last_tab_removed_; |
85 int last_tab_moved_from_; | 85 int last_tab_moved_from_; |
86 int last_tab_moved_to_; | 86 int last_tab_moved_to_; |
87 bool tabstrip_deleted_; | 87 bool tabstrip_deleted_; |
88 | 88 |
89 DISALLOW_COPY_AND_ASSIGN(TestTabStripObserver); | 89 DISALLOW_COPY_AND_ASSIGN(TestTabStripObserver); |
90 }; | 90 }; |
91 | 91 |
92 class TabStripTest : public views::ViewsTestBase { | 92 class TabStripTest : public views::ViewsTestBase { |
93 public: | 93 public: |
94 TabStripTest() | 94 TabStripTest() |
95 : controller_(NULL), | 95 : controller_(NULL), |
96 tab_strip_(NULL) { | 96 tab_strip_(NULL) { |
97 } | 97 } |
98 | 98 |
99 virtual ~TabStripTest() {} | 99 virtual ~TabStripTest() {} |
100 | 100 |
101 virtual void SetUp() OVERRIDE { | 101 virtual void SetUp() override { |
102 views::ViewsTestBase::SetUp(); | 102 views::ViewsTestBase::SetUp(); |
103 | 103 |
104 controller_ = new FakeBaseTabStripController; | 104 controller_ = new FakeBaseTabStripController; |
105 tab_strip_ = new TabStrip(controller_); | 105 tab_strip_ = new TabStrip(controller_); |
106 controller_->set_tab_strip(tab_strip_); | 106 controller_->set_tab_strip(tab_strip_); |
107 // Do this to force TabStrip to create the buttons. | 107 // Do this to force TabStrip to create the buttons. |
108 parent_.AddChildView(tab_strip_); | 108 parent_.AddChildView(tab_strip_); |
109 parent_.set_owned_by_client(); | 109 parent_.set_owned_by_client(); |
110 | 110 |
111 widget_.reset(new views::Widget); | 111 widget_.reset(new views::Widget); |
112 views::Widget::InitParams init_params = | 112 views::Widget::InitParams init_params = |
113 CreateParams(views::Widget::InitParams::TYPE_POPUP); | 113 CreateParams(views::Widget::InitParams::TYPE_POPUP); |
114 init_params.ownership = | 114 init_params.ownership = |
115 views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 115 views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
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 virtual void TearDown() OVERRIDE { | 121 virtual void TearDown() override { |
122 widget_.reset(); | 122 widget_.reset(); |
123 views::ViewsTestBase::TearDown(); | 123 views::ViewsTestBase::TearDown(); |
124 } | 124 } |
125 | 125 |
126 protected: | 126 protected: |
127 // Returns the rectangular hit test region of |tab| in |tab|'s local | 127 // Returns the rectangular hit test region of |tab| in |tab|'s local |
128 // coordinate space. | 128 // coordinate space. |
129 gfx::Rect GetTabHitTestMask(Tab* tab) { | 129 gfx::Rect GetTabHitTestMask(Tab* tab) { |
130 views::ViewTargeter* targeter = tab->targeter(); | 130 views::ViewTargeter* targeter = tab->targeter(); |
131 DCHECK(targeter); | 131 DCHECK(targeter); |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 ASSERT_TRUE(IsPointInTab(most_right_tab, unactive_overlap)); | 631 ASSERT_TRUE(IsPointInTab(most_right_tab, unactive_overlap)); |
632 | 632 |
633 EXPECT_EQ( | 633 EXPECT_EQ( |
634 right_tab, | 634 right_tab, |
635 FindTabView(tab_strip_->GetTooltipHandlerForPoint(unactive_overlap))); | 635 FindTabView(tab_strip_->GetTooltipHandlerForPoint(unactive_overlap))); |
636 | 636 |
637 // Confirm that tab strip doe not return tooltip handler for points that | 637 // Confirm that tab strip doe not return tooltip handler for points that |
638 // don't hit it. | 638 // don't hit it. |
639 EXPECT_FALSE(tab_strip_->GetTooltipHandlerForPoint(gfx::Point(-1, 2))); | 639 EXPECT_FALSE(tab_strip_->GetTooltipHandlerForPoint(gfx::Point(-1, 2))); |
640 } | 640 } |
OLD | NEW |