summaryrefslogtreecommitdiffstats
path: root/cc/test/fake_painted_scrollbar_layer.h
blob: 5e2fa1886edcbe1488603e00de83daa835e96e10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CC_TEST_FAKE_PAINTED_SCROLLBAR_LAYER_H_
#define CC_TEST_FAKE_PAINTED_SCROLLBAR_LAYER_H_

#include "base/memory/scoped_ptr.h"
#include "cc/layers/painted_scrollbar_layer.h"
#include "cc/test/fake_scrollbar.h"

namespace base { template<typename T> class AutoReset; }

namespace cc {

class FakePaintedScrollbarLayer : public PaintedScrollbarLayer {
 public:
  static scoped_refptr<FakePaintedScrollbarLayer>
      Create(bool paint_during_update, bool has_thumb, int scrolling_layer_id);
  int update_count() const { return update_count_; }
  void reset_update_count() { update_count_ = 0; }

  virtual bool Update(ResourceUpdateQueue* queue,
                      const OcclusionTracker<Layer>* occlusion) OVERRIDE;

  virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;

  scoped_ptr<base::AutoReset<bool> > IgnoreSetNeedsCommit();

  size_t push_properties_count() const { return push_properties_count_; }
  void reset_push_properties_count() { push_properties_count_ = 0; }

  // For unit tests
  UIResourceId track_resource_id() {
    return PaintedScrollbarLayer::track_resource_id();
  }
  UIResourceId thumb_resource_id() {
    return PaintedScrollbarLayer::thumb_resource_id();
  }
  FakeScrollbar* fake_scrollbar() {
    return fake_scrollbar_;
  }
  using PaintedScrollbarLayer::UpdateThumbAndTrackGeometry;

 private:
  FakePaintedScrollbarLayer(FakeScrollbar* fake_scrollbar,
                            int scrolling_layer_id);
  virtual ~FakePaintedScrollbarLayer();

  int update_count_;
  size_t push_properties_count_;
  FakeScrollbar* fake_scrollbar_;
};

}  // namespace cc

#endif  // CC_TEST_FAKE_PAINTED_SCROLLBAR_LAYER_H_