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

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

Issue 2590163004: Aura overlay scrollbars shouldn't invalidate thumb on scroll or enabled state. (Closed)
Patch Set: Forgot test file Created 4 years 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/ScrollbarThemeOverlay.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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "platform/scroll/ScrollbarThemeOverlay.h"
6
7 #include "platform/scroll/ScrollbarTestSuite.h"
8
9 namespace blink {
10
11 using testing::NiceMock;
12 using testing::Return;
13
14 class ScrollbarThemeOverlayTest : public ScrollbarTestSuite {};
15
16 TEST_F(ScrollbarThemeOverlayTest, PaintInvalidation) {
17 NiceMock<MockScrollableArea>* mockScrollableArea =
18 new NiceMock<MockScrollableArea>(ScrollOffset(100, 100));
19 ScrollbarThemeOverlay theme(14, 0, ScrollbarThemeOverlay::AllowHitTest);
20
21 Scrollbar* verticalScrollbar = Scrollbar::createForTesting(
22 mockScrollableArea, VerticalScrollbar, RegularScrollbar, &theme);
23 Scrollbar* horizontalScrollbar = Scrollbar::createForTesting(
24 mockScrollableArea, HorizontalScrollbar, RegularScrollbar, &theme);
25 ON_CALL(*mockScrollableArea, verticalScrollbar())
26 .WillByDefault(Return(verticalScrollbar));
27 ON_CALL(*mockScrollableArea, horizontalScrollbar())
28 .WillByDefault(Return(horizontalScrollbar));
29
30 IntRect verticalRect(1010, 0, 14, 768);
31 IntRect horizontalRect(0, 754, 1024, 14);
32 verticalScrollbar->setFrameRect(verticalRect);
33 horizontalScrollbar->setFrameRect(horizontalRect);
34
35 ASSERT_EQ(verticalScrollbar, mockScrollableArea->verticalScrollbar());
36 ASSERT_EQ(horizontalScrollbar, mockScrollableArea->horizontalScrollbar());
37
38 verticalScrollbar->clearTrackNeedsRepaint();
39 verticalScrollbar->clearThumbNeedsRepaint();
40 horizontalScrollbar->clearTrackNeedsRepaint();
41 horizontalScrollbar->clearThumbNeedsRepaint();
42 mockScrollableArea->clearNeedsPaintInvalidationForScrollControls();
43
44 ASSERT_FALSE(verticalScrollbar->thumbNeedsRepaint());
45 ASSERT_FALSE(verticalScrollbar->trackNeedsRepaint());
46 ASSERT_FALSE(mockScrollableArea->verticalScrollbarNeedsPaintInvalidation());
47 ASSERT_FALSE(horizontalScrollbar->thumbNeedsRepaint());
48 ASSERT_FALSE(horizontalScrollbar->trackNeedsRepaint());
49 ASSERT_FALSE(mockScrollableArea->horizontalScrollbarNeedsPaintInvalidation());
50
51 // Changing the scroll offset shouldn't invalide the thumb nor track, but it
52 // should cause a "general" invalidation for non-composited scrollbars.
53 // Ensure the horizontal scrollbar is unaffected.
54 mockScrollableArea->updateScrollOffset(ScrollOffset(0, 5), UserScroll);
55 verticalScrollbar->offsetDidChange();
56 horizontalScrollbar->offsetDidChange();
57 EXPECT_FALSE(verticalScrollbar->thumbNeedsRepaint());
58 EXPECT_FALSE(verticalScrollbar->trackNeedsRepaint());
59 EXPECT_TRUE(mockScrollableArea->verticalScrollbarNeedsPaintInvalidation());
60 EXPECT_FALSE(horizontalScrollbar->thumbNeedsRepaint());
61 EXPECT_FALSE(horizontalScrollbar->trackNeedsRepaint());
62 EXPECT_FALSE(mockScrollableArea->horizontalScrollbarNeedsPaintInvalidation());
63
64 // Try the horizontal scrollbar.
65 mockScrollableArea->clearNeedsPaintInvalidationForScrollControls();
66 mockScrollableArea->updateScrollOffset(ScrollOffset(5, 5), UserScroll);
67 horizontalScrollbar->offsetDidChange();
68 verticalScrollbar->offsetDidChange();
69 EXPECT_FALSE(verticalScrollbar->thumbNeedsRepaint());
70 EXPECT_FALSE(verticalScrollbar->trackNeedsRepaint());
71 EXPECT_FALSE(mockScrollableArea->verticalScrollbarNeedsPaintInvalidation());
72 EXPECT_FALSE(horizontalScrollbar->thumbNeedsRepaint());
73 EXPECT_FALSE(horizontalScrollbar->trackNeedsRepaint());
74 EXPECT_TRUE(mockScrollableArea->horizontalScrollbarNeedsPaintInvalidation());
75
76 mockScrollableArea->clearNeedsPaintInvalidationForScrollControls();
77
78 // Move the mouse over the vertical scrollbar's thumb. Ensure the thumb is
79 // invalidated as it's state is changed to hover.
skobes 2016/12/21 18:04:07 it's -> its
bokan 2016/12/22 15:02:31 Done.
80 verticalScrollbar->setHoveredPart(ThumbPart);
81 EXPECT_TRUE(verticalScrollbar->thumbNeedsRepaint());
82 EXPECT_TRUE(mockScrollableArea->verticalScrollbarNeedsPaintInvalidation());
83
84 verticalScrollbar->clearThumbNeedsRepaint();
85 mockScrollableArea->clearNeedsPaintInvalidationForScrollControls();
86
87 // Pressing down should also cause an invalidation.
88 verticalScrollbar->setPressedPart(ThumbPart);
89 EXPECT_TRUE(verticalScrollbar->thumbNeedsRepaint());
90 EXPECT_TRUE(mockScrollableArea->verticalScrollbarNeedsPaintInvalidation());
91
92 verticalScrollbar->clearThumbNeedsRepaint();
93 mockScrollableArea->clearNeedsPaintInvalidationForScrollControls();
94
95 // Release should cause invalidation.
96 verticalScrollbar->setPressedPart(NoPart);
97 EXPECT_TRUE(verticalScrollbar->thumbNeedsRepaint());
98 EXPECT_TRUE(mockScrollableArea->verticalScrollbarNeedsPaintInvalidation());
99
100 verticalScrollbar->clearThumbNeedsRepaint();
101 mockScrollableArea->clearNeedsPaintInvalidationForScrollControls();
102
103 // Move off should cause invalidation
104 verticalScrollbar->setHoveredPart(NoPart);
105 EXPECT_TRUE(verticalScrollbar->thumbNeedsRepaint());
106 EXPECT_TRUE(mockScrollableArea->verticalScrollbarNeedsPaintInvalidation());
107
108 verticalScrollbar->clearThumbNeedsRepaint();
109 mockScrollableArea->clearNeedsPaintInvalidationForScrollControls();
110
111 // Disabling the scrollbar is used to hide it so it should cause invalidation
112 // but only in the general sense since the compositor will have hidden it
113 // without a repaint.
114 verticalScrollbar->setEnabled(false);
115 EXPECT_FALSE(verticalScrollbar->thumbNeedsRepaint());
116 EXPECT_TRUE(mockScrollableArea->verticalScrollbarNeedsPaintInvalidation());
117
118 mockScrollableArea->clearNeedsPaintInvalidationForScrollControls();
119
120 verticalScrollbar->setEnabled(true);
121 EXPECT_FALSE(verticalScrollbar->thumbNeedsRepaint());
122 EXPECT_TRUE(mockScrollableArea->verticalScrollbarNeedsPaintInvalidation());
123
124 ThreadState::current()->collectAllGarbage();
125 }
126
127 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/scroll/ScrollbarThemeOverlay.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698