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 | 6 |
7 #include "chrome/browser/ui/tabs/tab_strip_selection_model.h" | 7 #include "chrome/browser/ui/tabs/tab_strip_selection_model.h" |
8 #include "chrome/browser/ui/views/tabs/tab_controller.h" | 8 #include "chrome/browser/ui/views/tabs/tab_controller.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "ui/views/test/views_test_base.h" | 10 #include "ui/views/test/views_test_base.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 params.bounds.SetRect(10, 20, 300, 400); | 69 params.bounds.SetRect(10, 20, 300, 400); |
70 widget.Init(params); | 70 widget.Init(params); |
71 | 71 |
72 FakeTabController tab_controller; | 72 FakeTabController tab_controller; |
73 Tab tab(&tab_controller); | 73 Tab tab(&tab_controller); |
74 widget.GetContentsView()->AddChildView(&tab); | 74 widget.GetContentsView()->AddChildView(&tab); |
75 tab.SetBoundsRect(gfx::Rect(gfx::Point(0, 0), Tab::GetStandardSize())); | 75 tab.SetBoundsRect(gfx::Rect(gfx::Point(0, 0), Tab::GetStandardSize())); |
76 | 76 |
77 // Tabs have some shadow in the top, so by default we don't hit the tab there. | 77 // Tabs have some shadow in the top, so by default we don't hit the tab there. |
78 int middle_x = tab.width() / 2; | 78 int middle_x = tab.width() / 2; |
79 EXPECT_FALSE(tab.HitTest(gfx::Point(middle_x, 0))); | 79 EXPECT_FALSE(tab.HitTestPoint(gfx::Point(middle_x, 0))); |
80 | 80 |
81 // Tabs are slanted, so a click halfway down the left edge won't hit it. | 81 // Tabs are slanted, so a click halfway down the left edge won't hit it. |
82 int middle_y = tab.height() / 2; | 82 int middle_y = tab.height() / 2; |
83 EXPECT_FALSE(tab.HitTest(gfx::Point(0, middle_y))); | 83 EXPECT_FALSE(tab.HitTestPoint(gfx::Point(0, middle_y))); |
84 | 84 |
85 // If the window is maximized, however, we want clicks in the top edge to | 85 // If the window is maximized, however, we want clicks in the top edge to |
86 // select the tab. | 86 // select the tab. |
87 widget.Maximize(); | 87 widget.Maximize(); |
88 EXPECT_TRUE(tab.HitTest(gfx::Point(middle_x, 0))); | 88 EXPECT_TRUE(tab.HitTestPoint(gfx::Point(middle_x, 0))); |
89 | 89 |
90 // But clicks in the area above the slanted sides should still miss. | 90 // But clicks in the area above the slanted sides should still miss. |
91 EXPECT_FALSE(tab.HitTest(gfx::Point(0, 0))); | 91 EXPECT_FALSE(tab.HitTestPoint(gfx::Point(0, 0))); |
92 EXPECT_FALSE(tab.HitTest(gfx::Point(tab.width() - 1, 0))); | 92 EXPECT_FALSE(tab.HitTestPoint(gfx::Point(tab.width() - 1, 0))); |
93 } | 93 } |
OLD | NEW |