Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: chrome/browser/ui/views/tabs/tab_unittest.cc

Issue 2360803002: Remove some pre-MD code from toolbar/tabstrip/frame. (Closed)
Patch Set: pkasting review Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 258
259 FakeTabController tab_controller; 259 FakeTabController tab_controller;
260 Tab tab(&tab_controller, nullptr); 260 Tab tab(&tab_controller, nullptr);
261 widget.GetContentsView()->AddChildView(&tab); 261 widget.GetContentsView()->AddChildView(&tab);
262 tab.SetBoundsRect(gfx::Rect(gfx::Point(0, 0), Tab::GetStandardSize())); 262 tab.SetBoundsRect(gfx::Rect(gfx::Point(0, 0), Tab::GetStandardSize()));
263 263
264 // Tabs are slanted, so a click halfway down the left edge won't hit it. 264 // Tabs are slanted, so a click halfway down the left edge won't hit it.
265 int middle_y = tab.height() / 2; 265 int middle_y = tab.height() / 2;
266 EXPECT_FALSE(tab.HitTestPoint(gfx::Point(0, middle_y))); 266 EXPECT_FALSE(tab.HitTestPoint(gfx::Point(0, middle_y)));
267 267
268 // Normally, tabs should not be hit if we click in the exclusion region, only 268 // Tabs should not be hit if we click above them.
269 // if we click below it.
270 const int exclusion = GetLayoutConstant(TAB_TOP_EXCLUSION_HEIGHT);
271 int middle_x = tab.width() / 2; 269 int middle_x = tab.width() / 2;
272 EXPECT_FALSE(tab.HitTestPoint(gfx::Point(middle_x, exclusion - 1))); 270 EXPECT_FALSE(tab.HitTestPoint(gfx::Point(middle_x, -1)));
273 EXPECT_TRUE(tab.HitTestPoint(gfx::Point(middle_x, exclusion))); 271 EXPECT_TRUE(tab.HitTestPoint(gfx::Point(middle_x, 0)));
274 272
275 // If the window is maximized, however, we want clicks in the top edge to 273 // Make sure top edge clicks still select the tab when the window is
276 // select the tab. 274 // maximized.
277 widget.Maximize(); 275 widget.Maximize();
278 EXPECT_TRUE(tab.HitTestPoint(gfx::Point(middle_x, 0))); 276 EXPECT_TRUE(tab.HitTestPoint(gfx::Point(middle_x, 0)));
279 277
280 // But clicks in the area above the slanted sides should still miss. 278 // But clicks in the area above the slanted sides should still miss.
281 EXPECT_FALSE(tab.HitTestPoint(gfx::Point(0, 0))); 279 EXPECT_FALSE(tab.HitTestPoint(gfx::Point(0, 0)));
282 EXPECT_FALSE(tab.HitTestPoint(gfx::Point(tab.width() - 1, 0))); 280 EXPECT_FALSE(tab.HitTestPoint(gfx::Point(tab.width() - 1, 0)));
283 } 281 }
284 282
285 TEST_F(TabTest, LayoutAndVisibilityOfElements) { 283 TEST_F(TabTest, LayoutAndVisibilityOfElements) {
286 static const TabAlertState kAlertStatesToTest[] = { 284 static const TabAlertState kAlertStatesToTest[] = {
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 } 488 }
491 489
492 TEST_F(TabTest, TitleHiddenWhenSmall) { 490 TEST_F(TabTest, TitleHiddenWhenSmall) {
493 FakeTabController tab_controller; 491 FakeTabController tab_controller;
494 Tab tab(&tab_controller, nullptr); 492 Tab tab(&tab_controller, nullptr);
495 tab.SetBounds(0, 0, 100, 50); 493 tab.SetBounds(0, 0, 100, 50);
496 EXPECT_GT(GetTitleWidth(tab), 0); 494 EXPECT_GT(GetTitleWidth(tab), 0);
497 tab.SetBounds(0, 0, 0, 50); 495 tab.SetBounds(0, 0, 0, 50);
498 EXPECT_EQ(0, GetTitleWidth(tab)); 496 EXPECT_EQ(0, GetTitleWidth(tab));
499 } 497 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_strip.cc ('k') | chrome/browser/ui/views/toolbar/toolbar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698