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

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

Issue 2588403002: TestingPlatformSupport: register Platform instance correctly (Closed)
Patch Set: review #32 Created 3 years, 11 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
(...skipping 13 matching lines...) Expand all
24 24
25 private: 25 private:
26 bool m_hasScrollbarButtons; 26 bool m_hasScrollbarButtons;
27 }; 27 };
28 28
29 } // namespace 29 } // namespace
30 30
31 class ScrollbarThemeAuraTest : public ScrollbarTestSuite {}; 31 class ScrollbarThemeAuraTest : public ScrollbarTestSuite {};
32 32
33 TEST_F(ScrollbarThemeAuraTest, ButtonSizeHorizontal) { 33 TEST_F(ScrollbarThemeAuraTest, ButtonSizeHorizontal) {
34 ScopedTestingPlatformSupport<TestingPlatformSupportWithMockScheduler,
35 const TestingPlatformSupport::Config&>
36 platform(m_config);
37
34 MockScrollableArea* mockScrollableArea = MockScrollableArea::create(); 38 MockScrollableArea* mockScrollableArea = MockScrollableArea::create();
35 ScrollbarThemeMock mockTheme; 39 ScrollbarThemeMock mockTheme;
36 Scrollbar* scrollbar = Scrollbar::createForTesting( 40 Scrollbar* scrollbar = Scrollbar::createForTesting(
37 mockScrollableArea, HorizontalScrollbar, RegularScrollbar, &mockTheme); 41 mockScrollableArea, HorizontalScrollbar, RegularScrollbar, &mockTheme);
38 ScrollbarThemeAuraButtonOverride theme; 42 ScrollbarThemeAuraButtonOverride theme;
39 43
40 IntRect scrollbarSizeNormalDimensions(11, 22, 444, 66); 44 IntRect scrollbarSizeNormalDimensions(11, 22, 444, 66);
41 scrollbar->setFrameRect(scrollbarSizeNormalDimensions); 45 scrollbar->setFrameRect(scrollbarSizeNormalDimensions);
42 IntSize size1 = theme.buttonSize(*scrollbar); 46 IntSize size1 = theme.buttonSize(*scrollbar);
43 EXPECT_EQ(66, size1.width()); 47 EXPECT_EQ(66, size1.width());
44 EXPECT_EQ(66, size1.height()); 48 EXPECT_EQ(66, size1.height());
45 49
46 IntRect scrollbarSizeSquashedDimensions(11, 22, 444, 666); 50 IntRect scrollbarSizeSquashedDimensions(11, 22, 444, 666);
47 scrollbar->setFrameRect(scrollbarSizeSquashedDimensions); 51 scrollbar->setFrameRect(scrollbarSizeSquashedDimensions);
48 IntSize size2 = theme.buttonSize(*scrollbar); 52 IntSize size2 = theme.buttonSize(*scrollbar);
49 EXPECT_EQ(222, size2.width()); 53 EXPECT_EQ(222, size2.width());
50 EXPECT_EQ(666, size2.height()); 54 EXPECT_EQ(666, size2.height());
51 55
52 ThreadState::current()->collectAllGarbage(); 56 ThreadState::current()->collectAllGarbage();
53 } 57 }
54 58
55 TEST_F(ScrollbarThemeAuraTest, ButtonSizeVertical) { 59 TEST_F(ScrollbarThemeAuraTest, ButtonSizeVertical) {
60 ScopedTestingPlatformSupport<TestingPlatformSupportWithMockScheduler,
61 const TestingPlatformSupport::Config&>
62 platform(m_config);
63
56 MockScrollableArea* mockScrollableArea = MockScrollableArea::create(); 64 MockScrollableArea* mockScrollableArea = MockScrollableArea::create();
57 ScrollbarThemeMock mockTheme; 65 ScrollbarThemeMock mockTheme;
58 Scrollbar* scrollbar = Scrollbar::createForTesting( 66 Scrollbar* scrollbar = Scrollbar::createForTesting(
59 mockScrollableArea, VerticalScrollbar, RegularScrollbar, &mockTheme); 67 mockScrollableArea, VerticalScrollbar, RegularScrollbar, &mockTheme);
60 ScrollbarThemeAuraButtonOverride theme; 68 ScrollbarThemeAuraButtonOverride theme;
61 69
62 IntRect scrollbarSizeNormalDimensions(11, 22, 44, 666); 70 IntRect scrollbarSizeNormalDimensions(11, 22, 44, 666);
63 scrollbar->setFrameRect(scrollbarSizeNormalDimensions); 71 scrollbar->setFrameRect(scrollbarSizeNormalDimensions);
64 IntSize size1 = theme.buttonSize(*scrollbar); 72 IntSize size1 = theme.buttonSize(*scrollbar);
65 EXPECT_EQ(44, size1.width()); 73 EXPECT_EQ(44, size1.width());
66 EXPECT_EQ(44, size1.height()); 74 EXPECT_EQ(44, size1.height());
67 75
68 IntRect scrollbarSizeSquashedDimensions(11, 22, 444, 666); 76 IntRect scrollbarSizeSquashedDimensions(11, 22, 444, 666);
69 scrollbar->setFrameRect(scrollbarSizeSquashedDimensions); 77 scrollbar->setFrameRect(scrollbarSizeSquashedDimensions);
70 IntSize size2 = theme.buttonSize(*scrollbar); 78 IntSize size2 = theme.buttonSize(*scrollbar);
71 EXPECT_EQ(444, size2.width()); 79 EXPECT_EQ(444, size2.width());
72 EXPECT_EQ(333, size2.height()); 80 EXPECT_EQ(333, size2.height());
73 81
74 ThreadState::current()->collectAllGarbage(); 82 ThreadState::current()->collectAllGarbage();
75 } 83 }
76 84
77 TEST_F(ScrollbarThemeAuraTest, NoButtonsReturnsSize0) { 85 TEST_F(ScrollbarThemeAuraTest, NoButtonsReturnsSize0) {
86 ScopedTestingPlatformSupport<TestingPlatformSupportWithMockScheduler,
87 const TestingPlatformSupport::Config&>
88 platform(m_config);
89
78 MockScrollableArea* mockScrollableArea = MockScrollableArea::create(); 90 MockScrollableArea* mockScrollableArea = MockScrollableArea::create();
79 ScrollbarThemeMock mockTheme; 91 ScrollbarThemeMock mockTheme;
80 Scrollbar* scrollbar = Scrollbar::createForTesting( 92 Scrollbar* scrollbar = Scrollbar::createForTesting(
81 mockScrollableArea, VerticalScrollbar, RegularScrollbar, &mockTheme); 93 mockScrollableArea, VerticalScrollbar, RegularScrollbar, &mockTheme);
82 ScrollbarThemeAuraButtonOverride theme; 94 ScrollbarThemeAuraButtonOverride theme;
83 theme.setHasScrollbarButtons(false); 95 theme.setHasScrollbarButtons(false);
84 96
85 scrollbar->setFrameRect(IntRect(1, 2, 3, 4)); 97 scrollbar->setFrameRect(IntRect(1, 2, 3, 4));
86 IntSize size = theme.buttonSize(*scrollbar); 98 IntSize size = theme.buttonSize(*scrollbar);
87 EXPECT_EQ(0, size.width()); 99 EXPECT_EQ(0, size.width());
88 EXPECT_EQ(0, size.height()); 100 EXPECT_EQ(0, size.height());
89 101
90 ThreadState::current()->collectAllGarbage(); 102 ThreadState::current()->collectAllGarbage();
91 } 103 }
92 104
93 } // namespace blink 105 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698