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

Unified Diff: third_party/WebKit/Source/platform/scroll/ScrollableAreaTest.cpp

Issue 1458703010: Mac: Don't repaint scrollbars every frame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master2
Patch Set: Fix tyop Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/scroll/ScrollableAreaTest.cpp
diff --git a/third_party/WebKit/Source/platform/scroll/ScrollableAreaTest.cpp b/third_party/WebKit/Source/platform/scroll/ScrollableAreaTest.cpp
index 13487d835d657377cc8cd2af7d229436487fdd1a..cf8ac98314345e874390090476e00ed25b6dd1d3 100644
--- a/third_party/WebKit/Source/platform/scroll/ScrollableAreaTest.cpp
+++ b/third_party/WebKit/Source/platform/scroll/ScrollableAreaTest.cpp
@@ -5,6 +5,8 @@
#include "config.h"
#include "platform/scroll/ScrollableArea.h"
+#include "platform/scroll/ScrollbarTheme.h"
+#include "platform/scroll/ScrollbarThemeMock.h"
#include "platform/testing/TestingPlatformSupport.h"
#include "public/platform/Platform.h"
#include "public/platform/WebScheduler.h"
@@ -127,4 +129,36 @@ TEST_F(ScrollableAreaTest, ScrollAnimatorCurrentPositionShouldBeSync)
EXPECT_EQ(100.0, scrollableArea->scrollAnimator()->currentPosition().y());
}
+TEST_F(ScrollableAreaTest, ScrollbarTrackAndThumbRepaint)
+{
+ ScrollbarTheme::setMockScrollbarsEnabled(true);
+ ScrollbarThemeMock::setShouldRepaintAllPartsOnInvalidation(true);
+
+ OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = MockScrollableArea::create(IntPoint(0, 100));
+ RefPtrWillBeRawPtr<Scrollbar> scrollbar = Scrollbar::create(scrollableArea.get(), HorizontalScrollbar, RegularScrollbar);
+
+ EXPECT_TRUE(scrollbar->trackBackgroudNeedsRepaint());
+ EXPECT_TRUE(scrollbar->thumbNeedsRepaint());
+ scrollbar->setNeedsPaintInvalidation();
+ EXPECT_TRUE(scrollbar->trackBackgroudNeedsRepaint());
+ EXPECT_TRUE(scrollbar->thumbNeedsRepaint());
+
+ scrollbar->setTrackBackgroudNeedsRepaint(false);
+ scrollbar->setThumbNeedsRepaint(false);
+ EXPECT_FALSE(scrollbar->trackBackgroudNeedsRepaint());
+ EXPECT_FALSE(scrollbar->thumbNeedsRepaint());
+ scrollbar->setNeedsPaintInvalidation();
+ EXPECT_TRUE(scrollbar->trackBackgroudNeedsRepaint());
+ EXPECT_TRUE(scrollbar->thumbNeedsRepaint());
+
+ ScrollbarThemeMock::setShouldRepaintAllPartsOnInvalidation(false);
+ scrollbar->setTrackBackgroudNeedsRepaint(false);
+ scrollbar->setThumbNeedsRepaint(false);
+ EXPECT_FALSE(scrollbar->trackBackgroudNeedsRepaint());
+ EXPECT_FALSE(scrollbar->thumbNeedsRepaint());
+ scrollbar->setNeedsPaintInvalidation();
+ EXPECT_FALSE(scrollbar->trackBackgroudNeedsRepaint());
+ EXPECT_FALSE(scrollbar->thumbNeedsRepaint());
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698