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

Side by Side Diff: third_party/WebKit/Source/platform/scroll/ScrollbarThemeAuraTest.cpp

Issue 2006643004: Fix scrollbar buttons on ChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove function in themeEngine Created 4 years, 6 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 | « third_party/WebKit/Source/platform/scroll/ScrollbarThemeAura.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "platform/scroll/ScrollbarThemeAura.h" 5 #include "platform/scroll/ScrollbarThemeAura.h"
6 6
7 #include "platform/scroll/ScrollbarTestSuite.h" 7 #include "platform/scroll/ScrollbarTestSuite.h"
8 8
9 namespace blink { 9 namespace blink {
10 10
11 using testing::Return; 11 using testing::Return;
12 12
13 namespace {
14
15 class ScrollbarThemeAuraButtonOverride final : public ScrollbarThemeAura {
16 public:
17 ScrollbarThemeAuraButtonOverride()
18 : m_hasScrollbarButtons(true)
19 {
20 }
21
22 void setHasScrollbarButtons(bool value)
23 {
24 m_hasScrollbarButtons = value;
25 }
26
27 bool hasScrollbarButtons(ScrollbarOrientation unused) const override
28 {
29 return m_hasScrollbarButtons;
30 }
31
32 private:
33 bool m_hasScrollbarButtons;
34 };
35
36 } // namespace
37
13 class ScrollbarThemeAuraTest : public ScrollbarTestSuite { 38 class ScrollbarThemeAuraTest : public ScrollbarTestSuite {
14 }; 39 };
15 40
16 TEST_F(ScrollbarThemeAuraTest, ButtonSizeHorizontal) 41 TEST_F(ScrollbarThemeAuraTest, ButtonSizeHorizontal)
17 { 42 {
18 MockScrollableArea* mockScrollableArea = MockScrollableArea::create(); 43 MockScrollableArea* mockScrollableArea = MockScrollableArea::create();
19 ScrollbarThemeMock mockTheme; 44 ScrollbarThemeMock mockTheme;
20 Scrollbar* scrollbar = Scrollbar::createForTesting( 45 Scrollbar* scrollbar = Scrollbar::createForTesting(
21 mockScrollableArea, HorizontalScrollbar, RegularScrollbar, &mockTheme); 46 mockScrollableArea, HorizontalScrollbar, RegularScrollbar, &mockTheme);
22 ScrollbarThemeAura theme; 47 ScrollbarThemeAuraButtonOverride theme;
23 48
24 IntRect scrollbarSizeNormalDimensions(11, 22, 444, 66); 49 IntRect scrollbarSizeNormalDimensions(11, 22, 444, 66);
25 scrollbar->setFrameRect(scrollbarSizeNormalDimensions); 50 scrollbar->setFrameRect(scrollbarSizeNormalDimensions);
26 IntSize size1 = theme.buttonSize(*scrollbar); 51 IntSize size1 = theme.buttonSize(*scrollbar);
27 EXPECT_EQ(66, size1.width()); 52 EXPECT_EQ(66, size1.width());
28 EXPECT_EQ(66, size1.height()); 53 EXPECT_EQ(66, size1.height());
29 54
30 IntRect scrollbarSizeSquashedDimensions(11, 22, 444, 666); 55 IntRect scrollbarSizeSquashedDimensions(11, 22, 444, 666);
31 scrollbar->setFrameRect(scrollbarSizeSquashedDimensions); 56 scrollbar->setFrameRect(scrollbarSizeSquashedDimensions);
32 IntSize size2 = theme.buttonSize(*scrollbar); 57 IntSize size2 = theme.buttonSize(*scrollbar);
33 EXPECT_EQ(222, size2.width()); 58 EXPECT_EQ(222, size2.width());
34 EXPECT_EQ(666, size2.height()); 59 EXPECT_EQ(666, size2.height());
35 60
36 ThreadHeap::collectAllGarbage(); 61 ThreadHeap::collectAllGarbage();
37 } 62 }
38 63
39 TEST_F(ScrollbarThemeAuraTest, ButtonSizeVertical) 64 TEST_F(ScrollbarThemeAuraTest, ButtonSizeVertical)
40 { 65 {
41 MockScrollableArea* mockScrollableArea = MockScrollableArea::create(); 66 MockScrollableArea* mockScrollableArea = MockScrollableArea::create();
42 ScrollbarThemeMock mockTheme; 67 ScrollbarThemeMock mockTheme;
43 Scrollbar* scrollbar = Scrollbar::createForTesting( 68 Scrollbar* scrollbar = Scrollbar::createForTesting(
44 mockScrollableArea, VerticalScrollbar, RegularScrollbar, &mockTheme); 69 mockScrollableArea, VerticalScrollbar, RegularScrollbar, &mockTheme);
45 ScrollbarThemeAura theme; 70 ScrollbarThemeAuraButtonOverride theme;
46 71
47 IntRect scrollbarSizeNormalDimensions(11, 22, 44, 666); 72 IntRect scrollbarSizeNormalDimensions(11, 22, 44, 666);
48 scrollbar->setFrameRect(scrollbarSizeNormalDimensions); 73 scrollbar->setFrameRect(scrollbarSizeNormalDimensions);
49 IntSize size1 = theme.buttonSize(*scrollbar); 74 IntSize size1 = theme.buttonSize(*scrollbar);
50 EXPECT_EQ(44, size1.width()); 75 EXPECT_EQ(44, size1.width());
51 EXPECT_EQ(44, size1.height()); 76 EXPECT_EQ(44, size1.height());
52 77
53 IntRect scrollbarSizeSquashedDimensions(11, 22, 444, 666); 78 IntRect scrollbarSizeSquashedDimensions(11, 22, 444, 666);
54 scrollbar->setFrameRect(scrollbarSizeSquashedDimensions); 79 scrollbar->setFrameRect(scrollbarSizeSquashedDimensions);
55 IntSize size2 = theme.buttonSize(*scrollbar); 80 IntSize size2 = theme.buttonSize(*scrollbar);
56 EXPECT_EQ(444, size2.width()); 81 EXPECT_EQ(444, size2.width());
57 EXPECT_EQ(333, size2.height()); 82 EXPECT_EQ(333, size2.height());
58 83
59 ThreadHeap::collectAllGarbage(); 84 ThreadHeap::collectAllGarbage();
60 } 85 }
61 86
87 TEST_F(ScrollbarThemeAuraTest, NoButtonsReturnsSize0)
88 {
89 MockScrollableArea* mockScrollableArea = MockScrollableArea::create();
90 ScrollbarThemeMock mockTheme;
91 Scrollbar* scrollbar = Scrollbar::createForTesting(
92 mockScrollableArea, VerticalScrollbar, RegularScrollbar, &mockTheme);
93 ScrollbarThemeAuraButtonOverride theme;
94 theme.setHasScrollbarButtons(false);
95
96 scrollbar->setFrameRect(IntRect(1, 2, 3, 4));
97 IntSize size = theme.buttonSize(*scrollbar);
98 EXPECT_EQ(0, size.width());
99 EXPECT_EQ(0, size.height());
100
101 ThreadHeap::collectAllGarbage();
102 }
103
62 } // namespace blink 104 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/scroll/ScrollbarThemeAura.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698