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

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

Issue 1401933004: Switch tab.cc to use an empty border for the contents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test Created 5 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
« no previous file with comments | « chrome/browser/ui/views/tabs/tab.cc ('k') | ui/views/border.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/ui/tabs/tab_utils.h" 9 #include "chrome/browser/ui/tabs/tab_utils.h"
10 #include "chrome/browser/ui/views/tabs/media_indicator_button.h" 10 #include "chrome/browser/ui/views/tabs/media_indicator_button.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 tab.close_button_->GetInsets().left()); 190 tab.close_button_->GetInsets().left());
191 } 191 }
192 if (tab.ShouldShowCloseBox()) { 192 if (tab.ShouldShowCloseBox()) {
193 // Note: The title bounds can overlap the left-insets of the close box, 193 // Note: The title bounds can overlap the left-insets of the close box,
194 // but should otherwise be to the left of the close button. 194 // but should otherwise be to the left of the close button.
195 if (tab.title_->width() > 0) { 195 if (tab.title_->width() > 0) {
196 EXPECT_LE(tab.title_->bounds().right(), 196 EXPECT_LE(tab.title_->bounds().right(),
197 tab.close_button_->bounds().x() + 197 tab.close_button_->bounds().x() +
198 tab.close_button_->GetInsets().left()); 198 tab.close_button_->GetInsets().left());
199 } 199 }
200 EXPECT_LE(tab.close_button_->bounds().right(), contents_bounds.right()); 200 // We need to use the close button contents bounds instead of its bounds,
201 EXPECT_LE(contents_bounds.y(), tab.close_button_->bounds().y()); 201 // since it has an empty border around it to extend its clickable area for
202 EXPECT_LE(tab.close_button_->bounds().bottom(), contents_bounds.bottom()); 202 // touch.
203 // Note: The close button right edge can be outside the nominal contents
204 // bounds, but shouldn't leave the local bounds.
205 const gfx::Rect close_bounds = tab.close_button_->GetContentsBounds();
206 EXPECT_LE(close_bounds.right(), tab.GetLocalBounds().right());
207 EXPECT_LE(contents_bounds.y(), close_bounds.y());
208 EXPECT_LE(close_bounds.bottom(), contents_bounds.bottom());
203 } 209 }
204 } 210 }
205 211
206 protected: 212 protected:
207 void InitWidget(Widget* widget) { 213 void InitWidget(Widget* widget) {
208 Widget::InitParams params(CreateParams(Widget::InitParams::TYPE_WINDOW)); 214 Widget::InitParams params(CreateParams(Widget::InitParams::TYPE_WINDOW));
209 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 215 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
210 params.bounds.SetRect(10, 20, 300, 400); 216 params.bounds.SetRect(10, 20, 300, 400);
211 widget->Init(params); 217 widget->Init(params);
212 } 218 }
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 EXPECT_EQ(50, tab.close_button_->bounds().height()); 406 EXPECT_EQ(50, tab.close_button_->bounds().height());
401 } 407 }
402 408
403 // Test in both a LTR and a RTL locale. Note: The fact that the UI code is 409 // Test in both a LTR and a RTL locale. Note: The fact that the UI code is
404 // configured for an RTL locale does *not* change how the coordinates are 410 // configured for an RTL locale does *not* change how the coordinates are
405 // examined in the tests above because views::View and friends are supposed to 411 // examined in the tests above because views::View and friends are supposed to
406 // auto-mirror the widgets when painting. Thus, what we're testing here is that 412 // auto-mirror the widgets when painting. Thus, what we're testing here is that
407 // there's no code in Tab that will erroneously subvert this automatic 413 // there's no code in Tab that will erroneously subvert this automatic
408 // coordinate translation. http://crbug.com/384179 414 // coordinate translation. http://crbug.com/384179
409 INSTANTIATE_TEST_CASE_P(, TabTest, ::testing::Values(false, true)); 415 INSTANTIATE_TEST_CASE_P(, TabTest, ::testing::Values(false, true));
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/tab.cc ('k') | ui/views/border.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698