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

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

Issue 2368653002: Remove pre-MD code from browser/ui/views/tabs/tab.cc (Closed)
Patch Set: fix compile Created 4 years, 3 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"
11 #include "chrome/browser/ui/layout_constants.h" 11 #include "chrome/browser/ui/layout_constants.h"
12 #include "chrome/browser/ui/tabs/tab_utils.h" 12 #include "chrome/browser/ui/tabs/tab_utils.h"
13 #include "chrome/browser/ui/views/tabs/alert_indicator_button.h" 13 #include "chrome/browser/ui/views/tabs/alert_indicator_button.h"
14 #include "chrome/browser/ui/views/tabs/tab_controller.h" 14 #include "chrome/browser/ui/views/tabs/tab_controller.h"
15 #include "chrome/grit/theme_resources.h" 15 #include "chrome/grit/theme_resources.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "ui/base/models/list_selection_model.h" 17 #include "ui/base/models/list_selection_model.h"
18 #include "ui/views/controls/button/image_button.h" 18 #include "ui/views/controls/button/image_button.h"
19 #include "ui/views/controls/label.h" 19 #include "ui/views/controls/label.h"
20 #include "ui/views/test/views_test_base.h" 20 #include "ui/views/test/views_test_base.h"
21 #include "ui/views/widget/widget.h" 21 #include "ui/views/widget/widget.h"
22 22
23 using views::Widget; 23 using views::Widget;
24 24
25 class FakeTabController : public TabController { 25 class FakeTabController : public TabController {
26 public: 26 public:
27 FakeTabController() {} 27 FakeTabController() {}
28 28
29 void set_immersive_style(bool value) { immersive_style_ = value; }
30 void set_active_tab(bool value) { active_tab_ = value; } 29 void set_active_tab(bool value) { active_tab_ = value; }
31 void set_paint_throbber_to_layer(bool value) { 30 void set_paint_throbber_to_layer(bool value) {
32 paint_throbber_to_layer_ = value; 31 paint_throbber_to_layer_ = value;
33 } 32 }
34 33
35 const ui::ListSelectionModel& GetSelectionModel() const override { 34 const ui::ListSelectionModel& GetSelectionModel() const override {
36 return selection_model_; 35 return selection_model_;
37 } 36 }
38 bool SupportsMultipleSelection() override { return false; } 37 bool SupportsMultipleSelection() override { return false; }
39 bool ShouldHideCloseButtonForInactiveTabs() override { 38 bool ShouldHideCloseButtonForInactiveTabs() override {
(...skipping 26 matching lines...) Expand all
66 const ui::MouseEvent& event) override {} 65 const ui::MouseEvent& event) override {}
67 bool ShouldPaintTab( 66 bool ShouldPaintTab(
68 const Tab* tab, 67 const Tab* tab,
69 const base::Callback<gfx::Path(const gfx::Size&)>& border_callback, 68 const base::Callback<gfx::Path(const gfx::Size&)>& border_callback,
70 gfx::Path* clip) override { 69 gfx::Path* clip) override {
71 return true; 70 return true;
72 } 71 }
73 bool CanPaintThrobberToLayer() const override { 72 bool CanPaintThrobberToLayer() const override {
74 return paint_throbber_to_layer_; 73 return paint_throbber_to_layer_;
75 } 74 }
76 bool IsImmersiveStyle() const override { return immersive_style_; }
77 SkColor GetToolbarTopSeparatorColor() const override { return SK_ColorBLACK; } 75 SkColor GetToolbarTopSeparatorColor() const override { return SK_ColorBLACK; }
78 int GetBackgroundResourceId(bool* custom_image) const override { 76 int GetBackgroundResourceId(bool* custom_image) const override {
79 *custom_image = false; 77 *custom_image = false;
80 return IDR_THEME_TAB_BACKGROUND; 78 return IDR_THEME_TAB_BACKGROUND;
81 } 79 }
82 void UpdateTabAccessibilityState(const Tab* tab, 80 void UpdateTabAccessibilityState(const Tab* tab,
83 ui::AXViewState* state) override{}; 81 ui::AXViewState* state) override{};
84 82
85 private: 83 private:
86 ui::ListSelectionModel selection_model_; 84 ui::ListSelectionModel selection_model_;
87 bool immersive_style_ = false;
88 bool active_tab_ = false; 85 bool active_tab_ = false;
89 bool paint_throbber_to_layer_ = true; 86 bool paint_throbber_to_layer_ = true;
90 87
91 DISALLOW_COPY_AND_ASSIGN(FakeTabController); 88 DISALLOW_COPY_AND_ASSIGN(FakeTabController);
92 }; 89 };
93 90
94 class TabTest : public views::ViewsTestBase { 91 class TabTest : public views::ViewsTestBase {
95 public: 92 public:
96 TabTest() {} 93 TabTest() {}
97 ~TabTest() override {} 94 ~TabTest() override {}
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 } 485 }
489 486
490 TEST_F(TabTest, TitleHiddenWhenSmall) { 487 TEST_F(TabTest, TitleHiddenWhenSmall) {
491 FakeTabController tab_controller; 488 FakeTabController tab_controller;
492 Tab tab(&tab_controller, nullptr); 489 Tab tab(&tab_controller, nullptr);
493 tab.SetBounds(0, 0, 100, 50); 490 tab.SetBounds(0, 0, 100, 50);
494 EXPECT_GT(GetTitleWidth(tab), 0); 491 EXPECT_GT(GetTitleWidth(tab), 0);
495 tab.SetBounds(0, 0, 0, 50); 492 tab.SetBounds(0, 0, 0, 50);
496 EXPECT_EQ(0, GetTitleWidth(tab)); 493 EXPECT_EQ(0, GetTitleWidth(tab));
497 } 494 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698