1 // Copyright 2013 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 #ifndef CC_TEST_FAKE_PAINTED_SCROLLBAR_LAYER_H_
6 #define CC_TEST_FAKE_PAINTED_SCROLLBAR_LAYER_H_
7 
8 #include <stddef.h>
9 
10 #include <memory>
11 
12 #include "cc/layers/painted_scrollbar_layer.h"
13 #include "cc/test/fake_scrollbar.h"
14 
15 namespace base { template<typename T> class AutoReset; }
16 
17 namespace cc {
18 
19 class FakePaintedScrollbarLayer : public PaintedScrollbarLayer {
20  public:
21   static scoped_refptr<FakePaintedScrollbarLayer> Create(
22       bool paint_during_update,
23       bool has_thumb,
24       ElementId scrolling_element_id = ElementId());
25   static scoped_refptr<FakePaintedScrollbarLayer> Create(
26       bool paint_during_update,
27       bool has_thumb,
28       ScrollbarOrientation orientation,
29       bool is_left_side_vertical_scrollbar,
30       bool is_overlay,
31       ElementId scrolling_element_id = ElementId());
update_count()32   int update_count() const { return update_count_; }
reset_update_count()33   void reset_update_count() { update_count_ = 0; }
34 
35   bool Update() override;
36 
37   void PushPropertiesTo(LayerImpl* layer) override;
38 
39   using PaintedScrollbarLayer::IgnoreSetNeedsCommit;
40 
push_properties_count()41   size_t push_properties_count() const { return push_properties_count_; }
reset_push_properties_count()42   void reset_push_properties_count() { push_properties_count_ = 0; }
43 
44   // For unit tests
track_resource_id()45   UIResourceId track_resource_id() {
46     return PaintedScrollbarLayer::track_resource_id();
47   }
thumb_resource_id()48   UIResourceId thumb_resource_id() {
49     return PaintedScrollbarLayer::thumb_resource_id();
50   }
fake_scrollbar()51   FakeScrollbar* fake_scrollbar() { return fake_scrollbar_; }
52   using PaintedScrollbarLayer::UpdateInternalContentScale;
53   using PaintedScrollbarLayer::UpdateThumbAndTrackGeometry;
54 
55  private:
56   FakePaintedScrollbarLayer(scoped_refptr<FakeScrollbar> fake_scrollbar,
57                             ElementId scrolling_element_id);
58   ~FakePaintedScrollbarLayer() override;
59 
60   int update_count_;
61   size_t push_properties_count_;
62   FakeScrollbar* fake_scrollbar_;
63 };
64 
65 }  // namespace cc
66 
67 #endif  // CC_TEST_FAKE_PAINTED_SCROLLBAR_LAYER_H_
68