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

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: test 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
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 : public ScrollbarThemeAura {
esprehn 2016/05/23 23:11:19 final
Bret 2016/05/23 23:44:06 Done.
16 public:
17 ScrollbarThemeAuraButtonOverride()
18 : m_hasScrollbarButtons(true)
19 {
20 }
21
22 bool m_hasScrollbarButtons;
esprehn 2016/05/23 23:11:19 no m_ if it's public, but can we just use a setter
Bret 2016/05/23 23:44:06 Sure. Done.
23
24 bool hasScrollbarButtons() const override
25 {
26 return m_hasScrollbarButtons;
27 }
28 };
29
30 } // namespace
31
13 class ScrollbarThemeAuraTest : public ScrollbarTestSuite { 32 class ScrollbarThemeAuraTest : public ScrollbarTestSuite {
14 }; 33 };
15 34
16 TEST_F(ScrollbarThemeAuraTest, ButtonSizeHorizontal) 35 TEST_F(ScrollbarThemeAuraTest, ButtonSizeHorizontal)
17 { 36 {
18 MockScrollableArea* mockScrollableArea = MockScrollableArea::create(); 37 MockScrollableArea* mockScrollableArea = MockScrollableArea::create();
19 ScrollbarThemeMock mockTheme; 38 ScrollbarThemeMock mockTheme;
20 Scrollbar* scrollbar = Scrollbar::createForTesting( 39 Scrollbar* scrollbar = Scrollbar::createForTesting(
21 mockScrollableArea, HorizontalScrollbar, RegularScrollbar, &mockTheme); 40 mockScrollableArea, HorizontalScrollbar, RegularScrollbar, &mockTheme);
22 ScrollbarThemeAura theme; 41 ScrollbarThemeAuraButtonOverride theme;
23 42
24 IntRect scrollbarSizeNormalDimensions(11, 22, 444, 66); 43 IntRect scrollbarSizeNormalDimensions(11, 22, 444, 66);
25 scrollbar->setFrameRect(scrollbarSizeNormalDimensions); 44 scrollbar->setFrameRect(scrollbarSizeNormalDimensions);
26 IntSize size1 = theme.buttonSize(*scrollbar); 45 IntSize size1 = theme.buttonSize(*scrollbar);
27 EXPECT_EQ(66, size1.width()); 46 EXPECT_EQ(66, size1.width());
28 EXPECT_EQ(66, size1.height()); 47 EXPECT_EQ(66, size1.height());
29 48
30 IntRect scrollbarSizeSquashedDimensions(11, 22, 444, 666); 49 IntRect scrollbarSizeSquashedDimensions(11, 22, 444, 666);
31 scrollbar->setFrameRect(scrollbarSizeSquashedDimensions); 50 scrollbar->setFrameRect(scrollbarSizeSquashedDimensions);
32 IntSize size2 = theme.buttonSize(*scrollbar); 51 IntSize size2 = theme.buttonSize(*scrollbar);
33 EXPECT_EQ(222, size2.width()); 52 EXPECT_EQ(222, size2.width());
34 EXPECT_EQ(666, size2.height()); 53 EXPECT_EQ(666, size2.height());
35 54
36 ThreadHeap::collectAllGarbage(); 55 ThreadHeap::collectAllGarbage();
37 } 56 }
38 57
39 TEST_F(ScrollbarThemeAuraTest, ButtonSizeVertical) 58 TEST_F(ScrollbarThemeAuraTest, ButtonSizeVertical)
40 { 59 {
41 MockScrollableArea* mockScrollableArea = MockScrollableArea::create(); 60 MockScrollableArea* mockScrollableArea = MockScrollableArea::create();
42 ScrollbarThemeMock mockTheme; 61 ScrollbarThemeMock mockTheme;
43 Scrollbar* scrollbar = Scrollbar::createForTesting( 62 Scrollbar* scrollbar = Scrollbar::createForTesting(
44 mockScrollableArea, VerticalScrollbar, RegularScrollbar, &mockTheme); 63 mockScrollableArea, VerticalScrollbar, RegularScrollbar, &mockTheme);
45 ScrollbarThemeAura theme; 64 ScrollbarThemeAuraButtonOverride theme;
46 65
47 IntRect scrollbarSizeNormalDimensions(11, 22, 44, 666); 66 IntRect scrollbarSizeNormalDimensions(11, 22, 44, 666);
48 scrollbar->setFrameRect(scrollbarSizeNormalDimensions); 67 scrollbar->setFrameRect(scrollbarSizeNormalDimensions);
49 IntSize size1 = theme.buttonSize(*scrollbar); 68 IntSize size1 = theme.buttonSize(*scrollbar);
50 EXPECT_EQ(44, size1.width()); 69 EXPECT_EQ(44, size1.width());
51 EXPECT_EQ(44, size1.height()); 70 EXPECT_EQ(44, size1.height());
52 71
53 IntRect scrollbarSizeSquashedDimensions(11, 22, 444, 666); 72 IntRect scrollbarSizeSquashedDimensions(11, 22, 444, 666);
54 scrollbar->setFrameRect(scrollbarSizeSquashedDimensions); 73 scrollbar->setFrameRect(scrollbarSizeSquashedDimensions);
55 IntSize size2 = theme.buttonSize(*scrollbar); 74 IntSize size2 = theme.buttonSize(*scrollbar);
56 EXPECT_EQ(444, size2.width()); 75 EXPECT_EQ(444, size2.width());
57 EXPECT_EQ(333, size2.height()); 76 EXPECT_EQ(333, size2.height());
58 77
59 ThreadHeap::collectAllGarbage(); 78 ThreadHeap::collectAllGarbage();
60 } 79 }
61 80
81 TEST_F(ScrollbarThemeAuraTest, NoButtonsReturnsSize0)
82 {
83 MockScrollableArea* mockScrollableArea = MockScrollableArea::create();
84 ScrollbarThemeMock mockTheme;
85 Scrollbar* scrollbar = Scrollbar::createForTesting(
86 mockScrollableArea, VerticalScrollbar, RegularScrollbar, &mockTheme);
87 ScrollbarThemeAuraButtonOverride theme;
88 theme.m_hasScrollbarButtons = false;
89
90 scrollbar->setFrameRect(IntRect(1, 2, 3, 4));
91 IntSize size = theme.buttonSize(*scrollbar);
92 EXPECT_EQ(0, size.width());
93 EXPECT_EQ(0, size.height());
94
95 ThreadHeap::collectAllGarbage();
96 }
97
62 } // namespace blink 98 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698